diff options
Diffstat (limited to 'alias-angular')
| -rw-r--r-- | alias-angular/app/js/controllers.js | 2 | ||||
| -rw-r--r-- | alias-angular/app/js/services.js | 40 |
2 files changed, 22 insertions, 20 deletions
diff --git a/alias-angular/app/js/controllers.js b/alias-angular/app/js/controllers.js index a4bc0d3..7eb5cbd 100644 --- a/alias-angular/app/js/controllers.js +++ b/alias-angular/app/js/controllers.js @@ -15,6 +15,6 @@ function RosterCtl($scope, connection, $log) { }; $log.log('sending the stanza'); var query = $iq({type : 'get'}).c('query', {xmlns : Strophe.NS.ROSTER}); - connection.sendIQ(query, $scope.onRoster); + $scope.$on('connected',function () {$log('caught connected event');connection.sendIQ(query, $scope.onRoster);}); }; RosterCtl.$inject = ['$scope','connection','$log'];
\ No newline at end of file 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 |
