我找不到手册如何加入聊天室并发送/接收消息?
我使用Strophe + openFire。
我如何发送消息:
var o = {from : 'test2@xmpp.local/5c5d4956', to:'1@conference.xmpp.local', type : 'groupchat', xmlns : Strophe.NS.MUC};
var m = $msg(o);
m.c('body', null, 'body text');
connection.send(m.tree());
我如何收到:
<body xmlns='http://jabber.org/protocol/httpbind'>
<message xmlns="jabber:client" xmlns="http://jabber.org/protocol/muc" from="1@conference.xmpp.local" to="test2@xmpp.local/77ce8c0e" type="error"> <body>dfsdfsdfsd</body><error xmlns="" code="406" type="modify"><not-acceptable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></message></body>
答案 0 :(得分:4)
加入会议室:
var o = {to:'roomName@conference.domain.com/youNick'};
var m = $pres(o);
m.c('x', {xmlns : 'http://jabber.org/protocol/muc#user'}, null);
connection.send(m.tree());
或者如果需要输入密码
var o = {to:'roomName@conference.domain.com/youNick'};
var m = $pres(o);
m.c('x', {xmlns : 'http://jabber.org/protocol/muc#user'}, null).c('password', null, 'pass');
connection.send(m.tree());
在房间发送消息:
var o = {to:'roomName@conference.domain.com', type : 'groupchat'};
var m = $msg(o); m.c('body', null, 'hello');
connection.send(m.tree());