我希望 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();
}