【问题标题】:strophe.js group invite - handler not triggeredstrophe.js 组邀请 - 未触发处理程序
【发布时间】:2013-12-07 15:30:39
【问题描述】:

我的邀请处理程序有问题。它永远不会被解雇。我可以看到来自群组的邀请:

<body xmlns='http://jabber.org/protocol/httpbind'>
        <message xmlns="jabber:client" from="epthi_795@conference.188.2.16.19" to="nikoladerikonjic@188.2.16.19">
            <x xmlns="http://jabber.org/protocol/muc#user">
                <invite from="sanjicabjelica@188.2.16.19">
                    <reason>Please join me in conference.</reason>
                </invite>
            </x>
            <x xmlns="jabber:x:conference" jid="epthi_795@conference.188.2.16.19"/>
        </message>
</body>

但是 on_message 处理程序没有被触发。因为没有定义类型。

当我输入Chat.connection.addHandler(Chat.on_message,null, "message", null,null,null,null);

显示邀请,但随后所有消息组或聊天都由它处理。我希望我能够拥有

Chat.connection.addHandler(Chat.on_message,null, "message", "chat");
Chat.connection.addHandler(Chat.on_message,null, "message", "groupchat");

用于不同类型的消息。

我用这个绕了两天。救命!?

换句话说,对于包含邀请的消息,应该在 addHandler 中添加什么?

更新

我必须放

Chat.connection.addHandler(Chat.on_message,null, "message"); 

在我邀请之前。

我不明白为什么会这样?有人知道吗?

【问题讨论】:

    标签: javascript php strophe libstrophe


    【解决方案1】:

    您开始使用的 2 个处理程序需要一个类型。邀请没有类型。我用于邀请的处理程序改为查找名称空间。这样它就与我的消息处理程序分开了。

    connection.addHandler(onInvite, 'jabber:x:conference');

    【讨论】:

    • 你能帮忙拒绝消息邀请吗?你使用了什么命名空间?你能给我看节吗?我有 var msg = $msg({"to" : from}).c("x", {"xmlns" : Strophe.NS.MUC_USER}).c("decline", {"to" : sender}) ;但这不起作用。你能帮忙吗?
    • 我只是添加了一个“动作”属性,并在我的 onInvite 被调用时查找它。
    • var msg = $msg({to: toJid, from: fromJid}).c('x', {xmlns: 'jabber:x:conference', jid: roomJid, action: 'deny ' })。树();连接().send(msg);
    • var action = el.getAttribute('action'); if(action==='deny'){//拒绝}
    猜你喜欢
    • 1970-01-01
    • 2021-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多