本文介绍了ClassCastException异常创造MUC空间使用aSmack XMPP群聊时,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 aSmack 创建聊天应用程序。当我创建群聊通过使用该 aSmack 提示错误。这是使用创建群聊

I am using aSmack for creating chat application. When i am creating groupchat by using this aSmack it gives error. this is the code am using for creating GroupChat.

MultiUserChat muc = new MultiUserChat(connection, "[email protected]");

try {
    muc.create(u_name);
    Form form = muc.getConfigurationForm();
    Form submitForm = form.createAnswerForm();
    for (Iterator<FormField> fields = form.getFields(); fields.hasNext();) {
        FormField field = (FormField) fields.next();
        if (!FormField.TYPE_HIDDEN.equals(field.getType()) && field.getVariable() != null) {
            submitForm.setDefaultAnswer(field.getVariable());
        }
    }
    List<String> owners = new ArrayList<String>();
    Log.i(TAG, "list of owners=====" +owners.toString());
    owners.add(PmUser_name);
    submitForm.setAnswer("muc#roomconfig_roomowners", owners);
    muc.sendConfigurationForm(submitForm);
} catch (XMPPException e) {
    e.printStackTrace();
}

这是我使用的罐子aSmack asmack-2010.05.07.jar 。它支持Facebook的XMPP,Gtalk的XMPP和我自己的服务器XMPP聊天。现在,我想创建群聊我自己的服务器,但它给这个错误。

This is the jar i am using for aSmack asmack-2010.05.07.jar. it supports facebook xmpp, Gtalk xmpp and my own server xmpp chat. Now i want to create group chat for my own server, but it give this error.

E/AndroidRuntime(31002): Caused by: java.lang.ClassCastException:
org.jivesoftware.smack.packet.DefaultPacketExtension
E/AndroidRuntime(31002):    at
org.jivesoftware.smackx.muc.MultiUserChat.getMUCUserExtension(MultiUserChat.java:2000)
E/AndroidRuntime(31002):    at
org.jivesoftware.smackx.muc.MultiUserChat.create(MultiUserChat.java:364)

我搜索了很多,但仍然没有得到关于如何解决这个任何想法。

I have search a lot but still didn't get any idea about how to solve this.

任何帮助将是之前,我拉我的头发AP preciated。

Any help would be appreciated before I pull my hair out.

推荐答案

嫌那里没有登记的包提供商。你得到一个 ClassCastException异常,因为拍击无法创建正确的数据包类实例的MUC。我建议你​​使用新aSmack 的版本,并遵循的,这应该初始化和注册商为您服务。

The Packet Providers of Smack where not registered. You get a ClassCastException because Smack is unable to create the correct Packet class instance for MUC. I suggest that you use a newer version of aSmack and follow the instructions in the README, which should initialize and register the Providers for you.

这篇关于ClassCastException异常创造MUC空间使用aSmack XMPP群聊时,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 12:04