【发布时间】:2014-08-06 13:40:59
【问题描述】:
带有 strophe 和 javascript 的基本 XMPP 想要转换为 AngularJS。
.controller('loginCtrl', function(xmppAuth) {
xmppAuth.auth(login, password);
})
并在服务中:
.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', '');
}
}
}
}
})
在js文件中
var on_presence = function(presence){
code
}
当我运行它时没有错误。但是所有处理事件,如 on_presence() 方法只调用一次。这是 Strophe Connection 对象的处理程序事件。这段代码中是否有任何剩余,或者我应该如何使用 angularJS 处理 strophes 事件?
我推荐了This Link,但它不起作用。
【问题讨论】:
标签: javascript angularjs xmpp strophe