我正在为我的聊天应用程序使用 asmack 库。我在成功登录后使用下面描述的代码来获取 Muc 房间信息:
MultiUserChat mMultiUserChat = new MultiUserChat(connection,"VjNewMoiosandroid@conference.chat"); mMultiUserChat.join(USERNAME); try { if (mMultiUserChat.isJoined()==true) { RoomInfo roomInfo=mMultiUserChat.getRoomInfo(connection,"VjNewMoiosandroid@conference.chat");} } catch (Exception e) { // TODO: handle exception e.printStackTrace(); }
我在获取房间信息时收到此错误,当我调试并检查我在日志中获取房间信息但房间信息中没有任何内容时。
10-10 08:55:12.388: W/System.err(1821): java.lang.ClassCastException: org.jivesoftware.smack.util.PacketParserUtils$2 不能转换为 org.jivesoftware.smackx.packet.DiscoverInfo 10-10 08:55:12.428: W/System.err(1821): 在 org.jivesoftware.smackx.ServiceDiscoveryManager.discoverInfo(ServiceDiscoveryManager.java:600) 10-10 08:55:12.458: W/System.err(1821):在 org.jivesoftware.smackx.ServiceDiscoveryManager.discoverInfo(ServiceDiscoveryManager.java:552) 10-10 08:55:12.478: W/System.err(1821): 在 com.demo.xmppchat.CopyOfXMPPChatDemoActivity.getRoomInfo(CopyOfXMPPChatDemoActivity.java: 469)
我在日志中收到的聊天室信息
10-10 15:38:10.133: D/SMACK(26035): 03:38:10 PM RCV (1107887640): <iq
from='VjNewMoiosandroid@conference.chat' to='14393671556301070000@chat/Smack'
id='VWaeO-6' type='result'><query xmlns='http://jabber.org/protocol/disco#info'><identity
category='conference' type='text' name='VjNewMoiosandroid'/><feature var='
http://jabber.org/protocol/muc'/><feature var='muc_public'/><feature
var='muc_persistent'/><feature var='muc_open'/><feature var='muc_semianonymous'/><feature
var='muc_moderated'/><feature var='muc_unsecured'/><x xmlns='jabber:x:data'
type='result'><field type='hidden' var='FORM_TYPE'><value>
http://jabber.org/protocol/muc#roominfo</value></field><field label='Room description'
var='muc#roominfo_description'><value></value></field><field label='Number of occupants'
var='muc#roominfo_occupants'><value>1</value></field></x></query></iq>