aboutsummaryrefslogtreecommitdiffstats
path: root/alias-angular/app/js/services.js
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2012-04-03 02:04:20 -0400
committerGuillaume Horel <guillaume.horel@gmail.com>2012-04-03 02:04:20 -0400
commit894f72e64e1557e74a9395682eeb200b63eea0d2 (patch)
treee826bc7a499ff6285d7eb454df9a2148ad40ba89 /alias-angular/app/js/services.js
parentd3cfd925dc6ffa1cfa9e410e7d725f765265a7f2 (diff)
downloadalias-894f72e64e1557e74a9395682eeb200b63eea0d2.tar.gz
last version
Diffstat (limited to 'alias-angular/app/js/services.js')
-rw-r--r--alias-angular/app/js/services.js40
1 files changed, 21 insertions, 19 deletions
diff --git a/alias-angular/app/js/services.js b/alias-angular/app/js/services.js
index 26113cb..1a3a96b 100644
--- a/alias-angular/app/js/services.js
+++ b/alias-angular/app/js/services.js
@@ -1,23 +1,25 @@
'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;
- }]);
+ $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);
+ };
+ }]);
}); \ No newline at end of file