【问题标题】:XMPP MUC how to permanently join a roomXMPP MUC 如何永久加入房间
【发布时间】:2015-05-17 06:31:15
【问题描述】:

我希望 XMPP 房间的机器人所有者一直在场,但我一直从房间里消失,不得不重新加入。我必须做些什么来保持我在房间里的存在?是否可配置?我在 XEP-0045 中找不到答案。

http://xmpp.org/extensions/xep-0045.html

这是我的代码:

function daemonPresence(callback) {
    var ElizaBot = require('./eliza');
    var eliza = new ElizaBot();
    var initial = eliza.getInitial();
    var XMPP = require('stanza.io');
    var administrator = 'metalaureate@' + config.get('xmpp.domain');
    var client = XMPP.createClient({
        jid: administrator, 
        password: 'password',
        transport: 'bosh',
        boshURL: config.get('xmpp.bosh_url') 

    });
    client.enableKeepAlive();

    client.on('session:started', function () {
        console.log(administrator + ' is sending presence');
       client.joinRoom("architecture@groups.xxxx.xxx", 'Daemon');
        setInterval(function () {client.sendPresence();console.log('daemon presence');},60000);

        client.on('chat', function (msg) {
            console.log(msg.body);
            var reply = eliza.transform(msg.body);
            client.sendMessage({
                to: msg.from,
                body: 'hello world' // 'You sent: ' + msg.body
            });
        });
        client.on('groupchat', function (msg) {
            console.log('group chat',  msg.body);

        });
    });
    client.on('session:end', function (result) {
        console.info("daemon session ended, restarting");
        setTimeout(function () {
            daemonPresence();
        }, 10000);
        // callback(null, result);
    });
    client.on('session:error', function (error) {
        console.err('xmpp error', error);
        callback(error, null);
    });

    client.connect();

}

【问题讨论】:

  • 检查运行你的机器人的机器是否在一段时间后没有休眠(例如,如果你从服务器以外的任何地方运行机器人,则始终开启)。

标签: node.js xmpp muc


【解决方案1】:

这是XEP-0045 中定义的 XMPP 多用户聊天的本质。 XMPP MUC 房间是基于存在的。这意味着您每次登录时都需要将您的状态发送到 MUC。这是协议中定义的。 一些客户端通过将书签实现为 XML 私有存储来解决此问题,以存储客户端将在连接时自动加入的 MUC 房间列表,您可能希望查看此内容。

XMPP 标准基金会正在讨论构建一个新的 MUC 规范(又名 MUC 2),该规范不会与在线状态相关联。不过,目前这只是一个讨论。

【讨论】:

  • 很抱歉这么久才接受这个。谢谢你的澄清。
猜你喜欢
  • 2012-10-18
  • 2016-10-25
  • 2017-04-21
  • 1970-01-01
  • 2016-04-09
  • 1970-01-01
  • 2018-10-05
  • 2012-09-13
  • 2019-03-06
相关资源
最近更新 更多