zupit.service('Zupit.Core.SignalR', [ 'Zupit.Core.NotificationService', 'config','$rootScope',function (notify, config,$rootScope) { var hub = $.connection[config.hub]; var started = false; if (hub !== undefined && hub !== null) { hub.client.notifyMessage = function (messageKey, parameters) { notify.info(messageKey, parameters); }; hub.client.newEvent = function (eventName) { $rootScope.$broadcast(eventName); }; } return { start:function(callback) { $.connection.hub.start().done(function () { started = true; callback(); }); }, login: function (name) { if ((hub !== undefined && hub !== null) && started) return hub.server.login(name); return 0; }, logout: function () { if ((hub !== undefined && hub !== null) && started) return hub.server.logout(); return 0; } }; } ]);