当我创建一对一聊天时,当我尝试加入群组聊天时,此功能非常有效,此错误显示了可能需要帮助的原因
我使用相同的连接进行单个聊天,并使用该连接加入群聊。
我的代码就是这个
public void groupChatter() {
Thread t1=new Thread(new Runnable() {
@Override
public void run() {
try {
mMultiUserChat = new MultiUserChat(connection, room + "@conference.nubes-pc-1");
// mMultiUserChat.create(room);
mMultiUserChat.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));
mMultiUserChat.join("test user 1");
PacketFilter filter = new MessageTypeFilter(Message.Type.groupchat);
connection.addPacketListener(new PacketListener()
{
@Override
public void processPacket(Packet packet)
{
Message message = (Message) packet;
if (message.getBody() != null)
{
String from = message.getFrom();
String Body = message.getBody();
// Add incoming message to the list view or similar
Log.d("Errro", from+" "+Body);
}
}
}, filter);
} catch (SmackException.NoResponseException e) {
e.printStackTrace();
} catch (XMPPException.XMPPErrorException e) {
e.printStackTrace();
} catch (SmackException.NotConnectedException e) {
e.printStackTrace();
} catch (SmackException e) {
e.printStackTrace();
}
}
});
t1.start();
}
02-16 17:11:07.028 24028-24245/nubes.logic.chatapp D/SMACK﹕ SENT (0): <iq id='gYQVr-4' to='room1@conference.nubes-pc-1' type='set'><query xmlns="http://jabber.org/protocol/muc#owner"><x xmlns='jabber:x:data' type='submit'></x></query></iq>
02-16 17:11:07.118 24028-24246/nubes.logic.chatapp D/SMACK﹕ RCV (0): <iq type="error" id="gYQVr-4" from="room1@conference.nubes-pc-1" to="test1@nubes-pc-1/Smack"><query xmlns="http://jabber.org/protocol/muc#owner"><x xmlns="jabber:x:data" type="submit"/></query><error code="401" type="auth"><not-authorized xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>
02-16 17:11:07.148 24028-24290/nubes.logic.chatapp W/System.err﹕ not-authorized
02-16 17:11:07.168 24028-24290/nubes.logic.chatapp W/System.err﹕ at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:196)
02-16 17:11:07.168 24028-24290/nubes.logic.chatapp W/System.err﹕ at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:175)
02-16 17:11:07.168 24028-24290/nubes.logic.chatapp W/System.err﹕ at org.jivesoftware.smackx.muc.MultiUserChat.sendConfigurationForm(MultiUserChat.java:590)
02-16 17:11:07.168 24028-24290/nubes.logic.chatapp W/System.err﹕ at nubes.logic.chatapp.MainActivity$4.run(MainActivity.java:205)
02-16 17:11:07.178 24028-24290/nubes.logic.chatapp W/System.err﹕ at java.lang.Thread.run(Thread.java:856)
答案 0 :(得分:0)
您需要保持房间的持久性,或者每次想要聊天时都要创建房间。 或者只是使用
mMultiUserChat.createOrJoin(room);