0

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, "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)
Thein
  • 3,940
  • 2
  • 30
  • 34

2 Answers2

1

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

Darya
  • 134
  • 3
0

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.

Andrew Dmytrenko
  • 380
  • 3
  • 11
  • Thanks for your reply. Is there any alternative way I can get room info from API not from sdk ? – Thein Dec 27 '13 at 19:08
  • You can save roomInfo in customObjects and than retrieve it. http://quickblox.com/developers/Custom_Objects#Create_new_record – Andrew Dmytrenko Dec 30 '13 at 08:25