0

addHandler 在调用 connect 之后和之前并且连接处理程序内部都不会捕获来自服务器的任何消息,有人知道这是什么吗?

var conn = new Strophe.Connection('http://example.org:7070/http-bind/');
conn.addHandler(function(iq){
console.log(iq);
return true;
}, null, 'message','event', null, 'pubsub.example.org', null);

conn.connect('nick13@example.org', 'password', function(status, err_cond){




if(status == Strophe.Status.CONNECTED)
{

$(document).trigger('connected');
}
else if(status == Strophe.Status.DISCONNECTED)
{
$(document).trigger('disconnected '+err_cond);
}
else if(status == Strophe.Status.CONNECTING)
{
alert('CONNECTING '+err_cond);
}
else if(status == Strophe.Status.DISCONNECTING)
{
alert('DISCONNECTING '+ err_cond);
}
$(document).bind('connected',function(){
alert('CONNECTED');

});
4

1 回答 1

0

您的 addHandler() 参数可能有问题:

'event'不是 XMPP 消息类型。我建议将其保留为 null(匹配所有类型),或检查您的 pubsub 组件使用什么(它将是“正常”或“标题”,并且可能是可配置的)。

于 2013-06-18T18:15:36.620 回答