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服務器來時迴應說,「你不能訂閱你自己「。
任何人有關於我在做什麼錯的想法?