aboutsummaryrefslogtreecommitdiffstats
path: root/app/js/services.js
blob: 1b1882e7b0f63659268dec073e38e1548f4c97b2 (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;
    }]);
});