首页 > 解决方案 > XMPPError:未找到项目 - 取消

问题描述

我正在使用xampp 和 Openfire在 android 中进行群聊。我在下面附加了用于加入聊天室的代码,但我收到一条错误消息 XMPPError: item-not-found - cancel

尽管我尝试了一些相关问题,但这些答案都没有帮助我。因此,如果有人可以帮助我,那就太好了。

public void joinChatRoom(String userName, String roomName) {
    try {
        Log.d("xmpp: ", "Service Name: " + connection.getServiceName());
    } catch (Exception e) {
        e.printStackTrace();
        Log.d("xmpp: ", "service name error: "+e.getMessage());
    }
    manager = MultiUserChatManager.getInstanceFor(connection);
    multiUserChat = manager.getMultiUserChat(roomName+ "@" +CHAT_ROOM_SERVICE_NAME + CHAT_SERVER_SERVICE_NAME);
    try {
        multiUserChat.join(userName);
    } catch (SmackException.NoResponseException e) {
        e.printStackTrace();
        Log.d("xmpp: ", "Chat room join Error: " + e.getMessage());
        sendBroadCast("joinerror", e.getMessage());
    } catch (XMPPException.XMPPErrorException e) {
        e.printStackTrace();
        Log.d("xmpp: ", "Chat room join Error: " + e.getMessage());
        sendBroadCast("joinerror", e.getMessage());
    } catch (SmackException.NotConnectedException e) {
        e.printStackTrace();
        Log.d("xmpp: ", "Chat room join Error: " + e.getMessage());
        sendBroadCast("joinerror", e.getMessage());
    }

    // if user joined successfully
    if (multiUserChat.isJoined()) {
        Log.d("xmpp: ", "user has Joined in the chat room");
        sendBroadCast("join", "done");
        //call method to configure room
        configRoom(roomName);

        // get Roster
        getBuddies();
        //get user info
        getUserInfo(userName);

     }
}

标签: androidandroid-studioxamppopenfiremultiuserchat

解决方案


我找到了答案。我刚刚更新了我的聊天对象。之前导入的类是错误的。现在它已通过以下行更正。

org.jivesoftware.smack.chat.Chat

推荐阅读