Thein
Thein

Reputation: 3968

Get trouble with XMPPConnection

I try to get Room info related with login user with QuickBlox sdk. I edited chat sample app and try to grab room info according to this => http://www.igniterealtime.org/builds/smack/docs/latest/documentation/extensions/index.html

MultiUserChat.getRoomInfo, MultiUserChat.getJoinedRooms are not worked ! Connection is successful.NullPointer exception occur in Iterator<String> joinedRooms = MultiUserChat.getJoinedRooms(connection, "[email protected]");

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 [email protected] has joined
                    Log.i("User Login =>", chatLogin);

                    Iterator<String> joinedRooms = MultiUserChat.getJoinedRooms(connection, "[email protected]");


                    /*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)

Upvotes: 0

Views: 417

Answers (2)

Darya
Darya

Reputation: 134

New SDK and chat sample with several improvements have been released.

Upvotes: 1

Andrew Dmytrenko
Andrew Dmytrenko

Reputation: 380

We almost finished working on our new sdk. We added new features for xmmp chat, increased stability. The sample will be released soon. You can try to use it for your project.

Upvotes: 0

Related Questions