로컬 ejabberd 2 서버를 실행 중이며 2 명의 사용자가 있습니다. [email protected]
및 [email protected]
. 두 사용자는 모두 ejabberd admin webportal에서 추가 된 명부에 서로 있습니다.node-xmpp를 사용하여 Adium을 통해 사용자를 온라인으로 표시
나는 jeremy
계정으로 로그인 한 OSX에서 adium을 사용하고 있습니다. 노드 콘솔을 사용하여 온라인으로 billy
계정 표시를보고 싶습니다. adium의 메시지 빌리와 노드 REPL의 jeremy 메시지를 허용하고 싶습니다.
var Client = require('node-xmpp-client'),
ltx = require('node-xmpp-core').ltx;
var client = new Client({jid: '[email protected]', password: 'password'});
client.on('online', function(data) {
console.log('Connected as ' + data.jid.user + '@' + data.jid.domain + '/' + data.jid.resource)
var presence = new ltx.Element('presence', { type: 'available' }).c('show').t('chat');
client.send(presence);
});
client.on('stanza', function(stanza) {
console.log('RECEIVED STANZA', stanza);
});
client.on('offline', function() {
console.log('Client is offline');
});
client.on('connect', function() {
console.log('Client is connected');
});
// log in
client.connect();
var message = new ltx.Element('message',{to: '[email protected]', type: 'chat'}).c('body').t('sup?');
// send message
client.send(message);
var roster = new ltx.Element('iq',{id: 'roster_0',type: 'get'}).c('query', { xmlns: 'jabber:iq:roster'});
// get roster
client.send(roster);
// log out
client.end();
나는 제레미 계정에 빌리 계정에서 메시지를 전송하고, 그 반대의 경우도 마찬가지 잘 할 수 있습니다. 그러나 빌리가 Adium에서 온라인으로 볼 수는 없습니다.
두 번 테스트하려면 "별표"라는 세 번째 사용자를 만들었습니다. 제레미 로스터에 "별표"를 추가 한 다음이 사용자를 Asterisk를 통해 설정합니다. I 이 사용자는 Adium을 통해 온라인으로 볼 수 있습니다.
누락 된 부분에 대한 의견이 있으십니까?