{"size": 743, "ext": "js", "max_stars_repo_path": "packages/socket/public/services/meanSocket.js", "max_stars_repo_name": "linkstatic12/marco3", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "packages/socket/public/services/meanSocket.js", "max_issues_repo_name": "linkstatic12/marco3", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "packages/socket/public/services/meanSocket.js", "max_forks_repo_name": "linkstatic12/marco3", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.7666666667, "max_line_length": 109, "alphanum_fraction": 0.6218034993}
/*global io:false*/
'use strict';

var baseUrl = 'http://localhost:3000/';

angular.module('mean.socket').factory('MeanSocket', function($rootScope) {
	var socket = io.connect({transports: ['websocket','xhr-polling','jsonp-polling','htmlfile','flashsocket']});
	return {
		on: function(eventName, callback) {
			socket.on(eventName, function() {
				var args = arguments;
				$rootScope.$apply(function() {
					callback.apply(socket, args);
				});
			});
		},
		emit: function(eventName, data, callback) {
			socket.emit(eventName, data, function() {
				console.log('event:', eventName);
				var args = arguments;
				$rootScope.$apply(function() {
					if (callback) {
						callback.apply(socket, args);
					}
				});
			});
		}
	};
});
