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');
});发布于 2013-06-19 02:15:37
可能是addHandler()参数有问题:
'event'不是XMPP消息类型。我建议将其保留为null (匹配所有类型),或者检查您的pubsub组件使用的是什么(它将是'normal‘或'headline',并且可能是可配置的)。
https://stackoverflow.com/questions/17152787
复制相似问题