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

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