Project

General

Profile

iOS: proper Tigase logout using XMPPFramework

Igor Khomenko
Added almost 5 years ago

Hi there,

I develop iOS application using https://github.com/robbiehanson/XMPPFramework as a client's library.

What I need to figure out is how to do properly Tigase logout when a user closes application.

iOS platform has a delegate

- (void)applicationWillTerminate:(UIApplication *)application
{
    // Called when the application is about to terminate.  
    // Your implementation of this method has approximately five seconds to perform any tasks and return. If the method does not return before time expires, the system may kill the process altogether.
} 

So, we have approximately 5 seconds to perform Chat logout.

What I do is:

  1. Send 'unavailable presence',

  2. Wait until receive callback, that presence was sent to server

  3. Send '/stream:stream'

  4. Close socket

Is it correct? Or I can skip something or add?

What I need to achieve is when user closed an app - Tigase server must think that my user is offline,

so I need to do properly Chat logout and don't stay for a while with ghost user

Anything I can add to prevent a situation with 'ghost user' ?


Replies (1)

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam almost 5 years ago

The workflow above is correct. Closing socket is the most important part as once the server discovers connection closed, it logs out the user and sends unavailable presence on his behalf. So the unavailable presence is not that important.

Unfortunately in case of mobile devices you usually do not have luxury of properly closing the socket. Mobile devices loose connection all the time and neither the mobile device or the server is notified about it. So you will have ghost users sometimes.

    (1-1/1)