我正在使用 aSmack(Android 的 Smack 端口)连接到 XMPP 服务器(Openfire 3.7.1)并与之通信。只要使用 MultiUserChat 类发送消息,我就可以让多用户聊天工作。但是,调用任何列出房间居住者的方法都会失败。相关代码:
setDefaultConnection();
if(connection!=null) {
mMuc = new MultiUserChat(connection, "hermitage_recycling@conference.jmartinw7");
try {
mMuc.join("chester");
mMuc.getModerators(); //line 71
ArrayList<Affiliate> dudes = new ArrayList<Affiliate>(mMuc.getMembers());
Iterator<Affiliate> iter = dudes.iterator();
while(iter.hasNext()) {
Affiliate dude = iter.next();
Log.w(this.getClass().getName(), dude.getNick());
}
} catch(XMPPException xmppe) {
Log.w(this.getClass().getName(), "MUC error: "+xmppe.getMessage());
}
}
日志猫:
07-10 13:38:56.248: ERROR/AndroidRuntime(13003): FATAL EXCEPTION: main
java.lang.ClassCastException: org.jivesoftware.smack.util.PacketParserUtils$2
at org.jivesoftware.smackx.muc.MultiUserChat.getOccupants(MultiUserChat.java:1797)
at org.jivesoftware.smackx.muc.MultiUserChat.getModerators(MultiUserChat.java:1761)
at org.apache.android.xmpp.XMPPClient$1.onClick(XMPPClient.java:71)
at android.view.View.performClick(View.java:2532)
图书馆有问题还是我做错了什么?getOccupants() 似乎有效。
MultiUserChat 示例和 javadocs:
http ://www.igniterealtime.org/builds/smack/docs/latest/javadoc/
http://www.igniterealtime.org/builds/smack/docs/latest/documentation/extensions/index.html
aSmack: http:
//code.google.com/p/asmack/
http://code.google.com/p/asmack/issues/detail?id=72