I am currently working on transitioning the basic XMPP setup using Strophe and JavaScript to AngularJS.
.controller('loginCtrl', function(xmppAuth) {
xmppAuth.auth(login, password);
})
and in service:
.service('xmppAuth', function() {
.return {
auth: function(login, password) {
connect = new Strophe.Connection(domain);
connect.connect(login, password, function (status) {
if (status === Strophe.Status.CONNECTED) {
connect.addHandler(on_roster_changed,"jabber:iq:roster", "iq", "set");
connect.addHandler(on_iq, null, "iq","");
connect.addHandler(on_presence, null, "presence");
connect.addHandler(on_message, null, 'message', '');
}
}
}
}
})
in js file
var on_presence = function(presence){
code
}
When I run this, there are no errors. However, all handling events like the on_presence() method are only being called once. This is a handler event of the Strophe Connection object. Is there anything missing in this code or what should be done for handling Strophe's events with AngularJS?
I found some guidance on This Link, but unfortunately it did not work for me.