android - 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);
}
}
解决方案
我找到了答案。我刚刚更新了我的聊天对象。之前导入的类是错误的。现在它已通过以下行更正。
org.jivesoftware.smack.chat.Chat
推荐阅读
- python - 没有切片和导入的滚动/滑动窗口迭代器?
- c# - 在 C# 中,对于长音频,Speaker Diarization 始终返回零
- vue.js - 访问功能性 vuejs 组件的渲染函数内的数据
- c - 使用 ARM64 中的 ARM Neon Intrinsic 对 64 位双精度值进行算术运算
- python - 在我的代码中使用 ginput 返回错误:matplotlib 当前正在使用非 GUI 后端
- angular - 如何在 Angular 5 项目中使用管道(过滤器)
- c# - 如何从列表中选择并使用 Automapper 映射另一个对象
- graphql - 任何查询都返回 TypeError: Failed to fetch in launchpad.graphql.com
- kotlin - 如何在 Kotlin 文档 Dokka/Kdoc 中转义符号?
- .net - 如何使资源字典中的部分文本加粗