2017-06-22 71 views
0

使用Ejabbered &嫌Android客戶端IM上delveloping聊天應用程序,每次用戶進入應用程序,我會把我的存在可用服務器&每次用戶離開應用程序,我要送的存在爲不可用,所以我可以接收之後發送的離線消息。但是,雖然我在離開應用程序時發送了存在數據包,但當我從不同的客戶端進行檢查時,仍然可以看到用戶在線。看着logcat的,我懷疑多連接還活着:的Android啪Ejabberd多個連接問題

已註銷:

--------------------------------- 
06-22 12:36:42.473 2985-3052/ask.around D/SMACK: SENT (0): <presence id='R0C81-14' type='unavailable'><priority>1</priority><show>away</show></presence><r xmlns='urn:xmpp:sm:3'/> 
06-22 12:36:42.474 2985-3052/ask.around D/SMACK: SENT (0): <presence id='R0C81-15' type='unavailable'></presence> 
06-22 12:36:42.475 2985-3052/ask.around D/SMACK: SENT (0): <a xmlns='urn:xmpp:sm:3' h='5'/> 
06-22 12:36:42.486 2985-3052/ask.around D/SMACK: SENT (0): 
06-22 12:36:42.487 2985-3052/ask.around D/SMACK: SENT (0): </stream:stream> 
06-22 12:36:42.616 2985-3053/ask.around D/SMACK: RECV (0): <a h='5' xmlns='urn:xmpp:sm:3'/> 
06-22 12:36:42.692 2985-3053/ask.around D/SMACK: RECV (0): </stream:stream> 
06-22 12:36:42.693 2985-3271/ask.around D/SMACK: XMPPConnection closed (XMPPTCPConnection[[email protected]/48305568695274620153122] (0)) 

沒有登出:

06-22 12:02:01.952 2586-3299/ask.around D/SMACK: SENT (2): <presence id='86IU1-48' type='unavailable'><priority>1</priority><show>away</show></presence><r xmlns='urn:xmpp:sm:3'/><presence id='86IU1-49' type='unavailable'></presence><a xmlns='urn:xmpp:sm:3' h='6'/> 
06-22 12:02:01.952 2586-3299/ask.around D/SMACK: SENT (2): </stream:stream> 
06-22 12:02:02.032 2586-3300/ask.around D/SMACK: RECV (2): <a h='5' xmlns='urn:xmpp:sm:3'/> 
06-22 12:02:02.052 2586-3282/ask.around D/SMACK: RECV (1): <presence xml:lang='en' to='[email protected]/104236288900606474493066' from='[email protected]/105858598794378801093074' type='unavailable' id='86IU1-48'><priority>1</priority><show>away</show></presence><r xmlns='urn:xmpp:sm:3'/> 
06-22 12:02:02.053 2586-3281/ask.around D/SMACK: SENT (1): <a xmlns='urn:xmpp:sm:3' h='7'/> 
06-22 12:02:02.099 2586-3300/ask.around D/SMACK: RECV (2): </stream:stream> 
06-22 12:02:02.100 2586-2938/ask.around D/SMACK: XMPPConnection closed (XMPPTCPConnection[[email protected]/105858598794378801093074] (2)) 

是什麼我做了錯誤,我的成功logcat的發現註銷數字總是零,n在不成功的一個它最多2,所以我創建多個連接?或者數字不是連接的否?如果它是連接數量的問題如何創建一個n唯一的實例,直到我的應用程序還活着?

回答

0

在進行連接之前,您可以大聲說出舊實例這可能對您有所幫助。

if(mXmpptcpConnection!=null){ 
     mXmpptcpConnection.instantShutdown(); 
    }