【问题标题】:How to get Openfire user presence in the chat room如何让 Openfire 用户出现在聊天室中
【发布时间】:2015-12-26 20:02:08
【问题描述】:

我使用 Openfire 3.10.2 XMPP 服务器和 Strophe 库作为客户端。我想通过推送通知向聊天室中所有未加入聊天室的用户发送消息。

如何让 Openfire 用户出现在聊天室中

有插件吗?

聊天室中的用户是否保存在数据库中? 我怎样才能做到这一点?

【问题讨论】:

    标签: xmpp openfire strophe user-presence muc


    【解决方案1】:

    你说过你会向IN聊天室中NOT JOIN聊天室的用户发送消息:这似乎是一个矛盾。如果用户没有加入房间,他就不在房间内,因此无法将房间内交换的消息也发送给该用户。

    关于房间状态,您不需要插件,但您可以中继连接到 Strophe.connection 的状态处理程序。这是一个例子:

    connection.addHandler(onPresence, null, "presence");
    

    ...

    function onPresence(presence) {
        var msg = $(presence);
        if (msg.children('x[xmlns^="' + Strophe.NS.MUC + '"]').length > 0) {
            // muc presence
            onRoomPresence(presence);
        } else {
            // user presence
            onUserPresence(presence);
        }
        return true;
    }
    

    不过,还有一个名为 MUC 的 Strophe 插件(请参阅strophe.muc.js

    【讨论】:

      猜你喜欢
      • 2013-11-08
      • 1970-01-01
      • 2017-01-07
      • 1970-01-01
      • 1970-01-01
      • 2014-07-26
      • 2019-01-27
      • 1970-01-01
      • 2012-10-27
      相关资源
      最近更新 更多