XMPPConnection 遇到问题
Posted
技术标签:
【中文标题】XMPPConnection 遇到问题【英文标题】:Get trouble with XMPPConnection 【发布时间】:2013-12-26 16:50:16 【问题描述】:我尝试使用QuickBlox
sdk 获取与登录用户相关的房间信息。我编辑了聊天示例应用程序并尝试根据此获取房间信息 => http://www.igniterealtime.org/builds/smack/docs/latest/documentation/extensions/index.html
MultiUserChat.getRoomInfo、MultiUserChat.getJoinedRooms 不起作用!连接成功。NullPointer
异常发生在Iterator<String> joinedRooms = MultiUserChat.getJoinedRooms(connection, "732374-5996@chat.quickblox.com");
public class MyChatController
// ================= QuickBlox ===== Step 8 =================
// Get QuickBlox chat server domain.
// There will be created connection with chat server below.
public static final String CHAT_SERVER = QBChat.getChatServerDomain();
private XMPPConnection connection;
private ConnectionConfiguration config;
private Chat chat;
private String chatLogin;
private String password;
private String friendLogin;
private ChatManager chatManager;
public MyChatController(String chatLogin, String password)
this.chatLogin = chatLogin;
this.password = password;
public void startChat(String buddyLogin)
this.friendLogin = buddyLogin;
new Thread(new Runnable()
@Override
public void run()
// Chat action 1 -- create connection.
Connection.DEBUG_ENABLED = true;
config = new ConnectionConfiguration(CHAT_SERVER);
connection = new XMPPConnection(config);
try
connection.connect();
connection.login(chatLogin, password);
// Chat action 2 -- create chat manager.
chatManager = connection.getChatManager();
// Chat action 3 -- create chat.
chat = chatManager.createChat(friendLogin, messageListener);
// Set listener for outcoming messages.
chatManager.addChatListener(chatManagerListener);
// Muc 2
if(connection != null)
// Get the rooms where user3@host.org has joined
Log.i("User Login =>", chatLogin);
Iterator<String> joinedRooms = MultiUserChat.getJoinedRooms(connection, "732374-5996@chat.quickblox.com");
/*while (joinedRooms.hasNext())
Log.i("Rooms =>", (String) joinedRooms.next());
*/
catch (XMPPException e)
e.printStackTrace();
).start();
Logcat =>
12-27 00:38:23.259: E/androidRuntime(15395): FATAL EXCEPTION: Thread-3743
12-27 00:38:23.259: E/AndroidRuntime(15395): java.lang.NullPointerException
12-27 00:38:23.259: E/AndroidRuntime(15395): at org.jivesoftware.smackx.muc.MultiUserChat.getRoomInfo(MultiUserChat.java:237)
12-27 00:38:23.259: E/AndroidRuntime(15395): at com.quickblox.sample.chat.MyChatController$3.run(MyChatController.java:95)
12-27 00:38:23.259: E/AndroidRuntime(15395): at java.lang.Thread.run(Thread.java:856)
【问题讨论】:
【参考方案1】:New SDK and chat sample 已发布多项改进。
【讨论】:
【参考方案2】:我们几乎完成了新 sdk 的开发。我们为 xmmp 聊天添加了新功能,增加了稳定性。样品将很快发布。您可以尝试将其用于您的项目。
【讨论】:
感谢您的回复。有没有其他方法可以从 API 而不是从 sdk 获取房间信息? 您可以将 roomInfo 保存在 customObjects 中,然后再检索它。 quickblox.com/developers/Custom_Objects#Create_new_record以上是关于XMPPConnection 遇到问题的主要内容,如果未能解决你的问题,请参考以下文章
获取 XMPPConnection 的 Nullpointer 异常
ClassNotFoundException 打击 XMPPConnection
aSmack 错误:XMPPConnection 是抽象的;无法实例化
我可以从并发线程调用 XMPPConnection.sendPacket 吗?
smack 中 XMPPConnection 的登录方法发生异常
aSmack连接server异常smack.SmackException$ ConnectionException thrown by XMPPConnection.connect();