'use strict'; angular.module('Alias.services', [], function($provide) { $provide.factory('connection', ['$log', function($log) { 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.'); } }; var connection = new Strophe.Connection(BOSH_SERVICE); connection.connect(NAME, PASSWORD, connect_callback); return connection; }]); });