2014-02-21 2 views
0

У меня есть следующий код, чтобы начать чат разговор между двумя пользователями:Избегайте XMPP сообщение «Не удается Subcribe к себе»

   // 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 +"[email protected]"); 
       connection.sendPacket(subscribe); 

       Presence subscribed = new Presence(Presence.Type.subscribed); 
       subscribed.setTo(str_receiver_chat_id +"[email protected]"); 
       connection.sendPacket(subscribed); 


       subscribe = new Presence(Presence.Type.subscribe); 
       subscribe.setTo(str_receiver_chat_id +"[email protected]"); 
       connection.sendPacket(subscribe); 


       subscribed = new Presence(Presence.Type.subscribed); 
       subscribed.setTo(str_your_chat_id +"[email protected]"); 
       connection.sendPacket(subscribed); 

Но когда она проходит сообщение приходит от сервера asmack отвечают, что «Вы не можете подписаться на себя ».

У кого-нибудь есть представление о том, что я делаю неправильно?

ответ

0

Что-то не так с этим кодом:

  // Set Subscription to receive user status 
      Presence subscribe = new Presence(Presence.Type.subscribe); 
      subscribe.setTo(str_your_chat_id +"[email protected]"); 
      connection.sendPacket(subscribe); 

Вы делаете подписку для себя, но вы не

Было бы здорово услышать, что вы хотели бы достичь