How to handle duplicate login

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

rafaelb149
Posts: 25
Joined: 28 Jun 2020, 08:54

How to handle duplicate login

Postby rafaelb149 » 28 Jun 2020, 10:29

Hi

We develop a mobile application that allows user to login only from a single device at once, hence if we detect during the login process that the user is already logged, we kick the existing user and connect the new one.

I noticed that when my client switches to Wifi or 4G and vice versa, I fall into the case of duplicate login, which means that the server didn't close the previous socket (client didn't send FIN), so he consider the new message as new client.

Please correct me if I'm wrong, and let me know what is the best practice to handle such migration (Wifi/4G) without user awareness.

Thanks,
Rafael
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How to handle duplicate login

Postby Lapo » 29 Jun 2020, 07:18

Hi,
we wrote an article on this subject in our blog:
https://smartfoxserver.com/blog/handlin ... e-devices/

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
rafaelb149
Posts: 25
Joined: 28 Jun 2020, 08:54

Re: How to handle duplicate login

Postby rafaelb149 » 09 Jul 2020, 09:46

Hi

I tried to implement it according to your suggestion above.
When I turn-off wifi (moving to mobile data) onConnectionLost triggers immediately with reason "unknown" before connectivity monitor detect network switch operation (I tried only Android for now).

Can you explain why we get connectionLost immediately?

Thanks :)
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How to handle duplicate login

Postby Lapo » 09 Jul 2020, 10:45

It just depends on what happens at the lower level in the OS TCP stack.
Depending on the TCP implementation you can get an immediate disconnection, nothing, a delayed disconnection etc...

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 141 guests