【问题标题】:Android Smack Ejabberd multiple connection issueAndroid Smack Ejabberd 多连接问题
【发布时间】:2017-11-25 09:23:39
【问题描述】:

我在 android 客户端上使用 Ejabbered 和 smack 开发聊天应用程序,每次用户进入应用程序时,我都会将我的状态发送给服务器,并且每次用户离开应用程序时,我都会将状态发送为不可用,这样我就可以接收离线消息在那之后发送..但是虽然我在离开应用程序时发送了存在数据包,但当我从不同的客户端检查时,我仍然可以看到用户在线。查看 logcat,我怀疑多个连接仍然存在:

退出:

---------------------------------
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[moulesh@ask-around-chat/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='moulesh@ask-around-chat/104236288900606474493066' from='moulesh@ask-around-chat/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[moulesh@ask-around-chat/105858598794378801093074] (2))

我犯了什么错误,我注意到在成功注销的 logcat 中,数字始终为零,在不成功的一个中,n 最多为 2,所以我是在创建多个连接吗?或者数字不是连接数??如果连接数有问题我如何创建一个仅 n 的实例,直到我的应用程序还活着?

【问题讨论】:

    标签: android ejabberd smack asmack


    【解决方案1】:

    您可以在建立连接之前喊出旧实例这可能会对您有所帮助。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-22
      • 2017-06-02
      • 1970-01-01
      • 2015-06-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多