Logout user from other devices when login from a different device

Gureen Ryuu
Added over 4 years ago

Is there an option to make Tigase log out the user from all other devices/connections he is logged on when he logs in from a new device?

As in, user is using Mobile A. When he logs in from mobile B, I want to log him out from mobile A. Is that possible?

Replies (4)

Added by Steffen Larsen over 4 years ago

I've done this before. You can do it by implementing a processor that basically looks at your incoming connections and resources and can do the disconnect.

So basically you need to extends XMPPProcessor and implements XMPPProcessorIfc. And implement the process method to do your business logic.

Added by Gureen Ryuu over 4 years ago

I was thinking of that, yes.

But what would it listen to? Login XMLNS @urn:ietf:params:xml:ns:xmpp-sasl@? How would I know it's successful?

Or should I modify the SaslAuth plugin to logout the user from other connections when successful? Or will that cause a problem?


Added by Artur Hefczyc TigaseTeam over 4 years ago

This is already done in the resource bind plugin. If you login a user second time using the same resource, the old one would be automatically logged out. If this is not good enough solution for you, than, as Steffen said, you need to implement a new processor. I would suggest to listen for resource bind XMLNS as this way you are sure that the login process has been successfully completed.


Added by Artur Hefczyc TigaseTeam over 4 years ago

Just thinking, maybe a better solution would be to modify the code which disconnects the old connection for the same resource (in XMPPSession) to have an option for max number of user connections. When it is exceeded than the oldest connections would be dropped. Then when you set this to 1 it would work the way you want.