From 0576a6276cfbf435fba4fd8d8b2e984ab91104b3 Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Fri, 6 Apr 2012 19:17:54 -0400 Subject: Finally fixed the angular code! --- alias-angular/app/js/services.js | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'alias-angular/app/js/services.js') 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 -- cgit v1.2.3-70-g09d2