0

I have the following code to start a chat conversation between two users:

               // Create Connection.
                Connection.DEBUG_ENABLED = true;
                config     = new ConnectionConfiguration(CHAT_SERVER);
                connection = new XMPPConnection(config);
                connection.connect();
                connection.login(chatLogin, password);

                // Create Chat Manager.
                chatManager = connection.getChatManager();

                // Create Chat.
                chat = chatManager.createChat(friendLogin, messageListener);

                // Set listener for outcoming messages.
                chatManager.addChatListener(chatManagerListener);

                String str_your_chat_id     = Integer.toString(your_chat_id);
                String str_receiver_chat_id = Integer.toString(receiver_chat_id);

                // Set Subscription to receive user status
                Presence subscribe = new Presence(Presence.Type.subscribe);
                subscribe.setTo(str_your_chat_id +"-3758@chat.quickblox.com");
                connection.sendPacket(subscribe);

                Presence subscribed = new Presence(Presence.Type.subscribed);
                subscribed.setTo(str_receiver_chat_id +"-3758@chat.quickblox.com");
                connection.sendPacket(subscribed);


                subscribe = new Presence(Presence.Type.subscribe);
                subscribe.setTo(str_receiver_chat_id +"-3758@chat.quickblox.com");
                connection.sendPacket(subscribe);


                subscribed = new Presence(Presence.Type.subscribed);
                subscribed.setTo(str_your_chat_id +"-3758@chat.quickblox.com");
                connection.sendPacket(subscribed);

But when it runs a message coming from the asmack server respond that "You can not subscribe to yourself".

Anyone has an idea about what I am doing wrong?

MarcForn
  • 3,321
  • 7
  • 25
  • 39

1 Answers1

0

Something wrong with this code:

            // Set Subscription to receive user status
            Presence subscribe = new Presence(Presence.Type.subscribe);
            subscribe.setTo(str_your_chat_id +"-3758@chat.quickblox.com");
            connection.sendPacket(subscribe);

You do a subscription for yourself, but you don't

Would be great to hear what you would like to achieve

Rubycon
  • 18,156
  • 10
  • 49
  • 70