aboutsummaryrefslogtreecommitdiffstats
path: root/alias-angular/app/js/services.js
blob: 1a3a96bd8c2da804350008bb715b3af2e0e6427d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
'use strict';

angular.module('Alias.services', [], function($provide) {
    $provide.factory('connection', ['$log', '$rootScope',
        function($log, $rootScope) {
            function connect_callback(status){
                if ( status == Strophe.Status.CONNECTING ) {
                    $log.log('Strophe is connecting.');
                } else if ( status == Strophe.Status.CONNFAIL ) {
                    $log.log('Strophe failed to connect.');
                } else if ( status == Strophe.Status.DISCONNECTING ) {
                    $log.log('Strophe is disconnecting.');
                } else if ( status == Strophe.Status.DISCONNECTED ) {
                    $log.log('Strophe is disconnected.');
                } else if ( status == Strophe.Status.CONNECTED ) {
                    $log.log('Strophe is connected.');
                    cb();
                }
            };
            var connection = new Strophe.Connection(BOSH_SERVICE);
            return function(cb) {
                connection.connect(NAME, PASSWORD, connect_callback);
            };
        }]);
});