diff options
| author | Guillaume Horel <guillaume.horel@gmail.com> | 2012-04-06 19:17:54 -0400 |
|---|---|---|
| committer | Guillaume Horel <guillaume.horel@gmail.com> | 2012-04-06 19:17:54 -0400 |
| commit | 0576a6276cfbf435fba4fd8d8b2e984ab91104b3 (patch) | |
| tree | 4fea21d0dcdd9bfa1edad00143baa1b6e153bbd4 /alias-angular/app/js/services.js | |
| parent | 894f72e64e1557e74a9395682eeb200b63eea0d2 (diff) | |
| download | alias-0576a6276cfbf435fba4fd8d8b2e984ab91104b3.tar.gz | |
Finally fixed the angular code!
Diffstat (limited to 'alias-angular/app/js/services.js')
| -rw-r--r-- | alias-angular/app/js/services.js | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/alias-angular/app/js/services.js b/alias-angular/app/js/services.js index 1a3a96b..7b9e285 100644 --- a/alias-angular/app/js/services.js +++ b/alias-angular/app/js/services.js @@ -1,25 +1,16 @@ 'use strict'; angular.module('Alias.services', [], function($provide) { - $provide.factory('connection', ['$log', '$rootScope', + $provide.factory('StropheSrv', ['$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); + this.login = function(name, password, connect_callback) { + connection.connect(name, password, function(status){ $rootScope.$apply(connect_callback(status));}); + }; + this.sendIQ = function(query, callback) { + connection.sendIQ(query, function(data){ + $rootScope.$apply(callback(data));}); }; + return this; }]); });
\ No newline at end of file |
