Forced Logout Question

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

Moderators: Lapo, Bax

Post Reply
jgrotto
Posts: 5
Joined: 29 Jan 2012, 17:21

Forced Logout Question

Post by jgrotto »

Hi,

Is it possible to determine if a user was logged out based on a forced logout condition? In other words, if a user logs in and that forces the logout of another client, is there a way to identify this through a Logout or Disconnect Event?

In this case, I would like to have my application show a dialog stating that the user was logged out because they logged in elsewhere.

Thanks!
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Forced Logout Question

Post by rjgtav »

Hello.
Currently, when you're disconnected due to the forceLogout feature, you only get a CONNECTION_LOST event with reason set to unknown, and you are neither able to customize it nor to distinguish it from a "normal" disconnection. That said, as a workaround, you could disable the force logout and before you login the new user, you check if there is other already logged in. If there is, you send it a small packet with a simple command (which will mean that the client was kicked because of the multiple login) and then disconnect the user.

Maybe this could be a feature request, to implement a new DisconnectionReason for when you are disconnected due to the forceLogout system.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Forced Logout Question

Post by Lapo »

You mean on client or server side?
On the server side you do get a disconnection event so you can check who was disconnected. On the client this is not possible.
Lapo
--
gotoAndPlay()
...addicted to flash games
jgrotto
Posts: 5
Joined: 29 Jan 2012, 17:21

Re: Forced Logout Question

Post by jgrotto »

Thanks for the responses.

To answer your question, similar to the existing reason codes returned on a user disconnect (kick, ban, etc.). I'm trying to come up with a way to determine (on the client) that a user was logged out because they logged in somewhere else. So let's say I'm logged in from my laptop. With force login configured, if I then log in from my desktop PC using the same user, my laptop gets logged out. I would like the laptop client to recognize this condition. Not simply that I was logged off, but that it was the result of logging in someplace else.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Forced Logout Question

Post by Lapo »

I am sorry, this is not supported.
Also, in general, it would make little sense IMHO. You normally don't want clients to remain idle for hours and hours. SFS2X already provides a disconnection mechanism for idle clients. This means that, in your described scenario, you will probably disconnected by the server before you attempt a new login from some other place.

When this happens, the client is actually given a disconnection reason. On the other hand when you login from some other place this is not possible, because it involves sending a message to the other client and delaying the new user's login.

I will add a note in our to-do list for future improvements.
Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
woosh
Posts: 13
Joined: 30 Jul 2012, 16:52

Re: Forced Logout Question

Post by woosh »

Well, it does make sense if you do not want the user to open two browser windows and play against self. Alternative (custom login) seems to be too much just for this.

Too bad.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Forced Logout Question

Post by Lapo »

I don't understand your comment.
A user can register two accounts and play against himself. To avoid this you must enable the IP filter and allow only one connection per IP.

This also comes with some side effects: you can never say if two connections coming from the same IP address are from the same player or not. Imagine an office or a school where dozens of people have access to the internet, all from the same IP.
Lapo
--
gotoAndPlay()
...addicted to flash games
woosh
Posts: 13
Joined: 30 Jul 2012, 16:52

Re: Forced Logout Question

Post by woosh »

And what if two accounts for the same user are OK but playing against self is not?
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Forced Logout Question

Post by rjgtav »

Hi.
In that case, you have to store the user's display name as an UserVariable, and then you could login your users as guests, so they would get their unique guest username.
Isn't a player logged in multiple times with the same account considered as cheating?
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Post Reply