【发布时间】:2018-10-15 08:37:32
【问题描述】:
我正在开发 android 聊天应用程序(xmpp 服务器 -prosody- 和 android smack 库) 我成功创建了群组房间并邀请了成员,但是当我尝试向群组发送消息时出现此节错误:
<message to='rokayah89@eonaws.com/Roo' from='room31@conference.eonaws.com' id='123' type='error'><error type='cancel'><not-acceptable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></message>
我的发送消息代码:
MultiUserChat muc = manager.getMultiUserChat(roomBarJid);
Message msg = new Message(roomBarJid);
msg.setType(Message.Type.groupchat);
msg.setBody("Hi there");
msg.setStanzaId("123");
msg.setSubject("Rokayah ..... ");
msg.setTo(roomBarJid);
try {
if (muc != null) {
muc.sendMessage(msg);
} Log.d("GROUP", "The message send..............");
} catch (SmackException.NotConnectedException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
这是接收消息的监听器:
StanzaFilter filter = new StanzaTypeFilter(Message.class);
mConnection.addSyncStanzaListener(new StanzaListener() {
@Override
public void processStanza(Stanza packet) throws SmackException.NotConnectedException, InterruptedException, SmackException.NotLoggedInException {
Message message = (Message) packet;
String body = message.getBody();
Log.d("GROUP" , "here :" +body);
}
}, filter);
我不知道发送和接收监听器给我空消息正文有什么问题。
任何帮助请!!
【问题讨论】:
-
我假设你正在使用 XMPP MUC;根据 MUC 的实现,这个错误意味着你不是群组的成员,所以可能有两个原因:1.你还没有加入房间 2.你不允许发送消息 请解释一下你在做什么问题的确切说明。