How to Properly Logout using Smack4.1.4 XMPPTCPConnection

I am confused that there is no “logout” function in XMPPTCPConnection, and .disconnect() does not return a value indicates whether the logout is successful or not.

Does anyone user Smack4.1.4 on android before? Can Share me some idea on how to implement it? Thx

disconnect() will try to logout and terminate the TCP connection.

perhaps you didn’t get my problem. The problem is disconnect() return type is void, how do I know the server side receive the request? If my side is cut off from internet or have poor net connection, disconnect() will not tell me whether it is success or not. my local thought I was logout but server does not. Next time I will not be able to login because the server thought the account is already login

Next time I will not be able to login because the server thought the account is already login

That depends, but in general is never a problem you would only be able to handle it disconnect() would return a boolean. XMPP supports multiple connections by the same account per design. If the server’s resource conflict policy is not set to “kick older”, then you will have that problem. But even then you could catch the resource-conflict exception and simply choose another resource on login().

But ideally the server’s resource conflict policy is set to “kick older” and you let the server assign resources to you, i.e. login with ‘null’ as resource. You should also remember the assigned resource and use if on successive logins.

ok thx