(function () {
    'use strict';
 
    angular.module('magneto').factory('fastChatHub', function ($http, $q, 
ngAuthSettings, API_CONNECTIONS, localStorageService) {
        var listeners = [];
        var fastChat = $.connection.fastChatHub;
        var apiRoot = API_CONNECTIONS.ROOT;
        var apiHub = API_CONNECTIONS.HUB_URL;
        
        var token = localStorageService.get('authorizationData').token;
        $.signalR.ajaxDefaults.headers = { Authorization: "Bearer " + token };
 
        fastChat.client.getMessage = function () {
            listeners.forEach(function (cb) {
                cb(args);
            });
        };
 
        $.connection.hub.url = 'http://localhost:36722/SignalR';
        $.connection.hub.logging = true;
        $.connection.hub.start({ transport: ['longPolling'] }).
            done(function () {
                console.log('Now connected, connection ID=' + 
$.connection.hub.id);
            }).
            fail(function () {
                console.log('Could not Connect!');
            });
 
        return {
            sendMessage: function (message) {
                console.log('sendMessage ');
                fastChat.server.sendMessage(message);
            },
            onMessage: function (callback) {
                console.log('recive message');
                listeners.push(callback);
            }
        };
    });
})();

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to