Can I set that only one user can login at a time for all zone?

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

Moderators: Lapo, Bax

pop2518
Posts: 16
Joined: 10 Jan 2012, 11:23

Can I set that only one user can login at a time for all zone?

Postby pop2518 » 28 May 2019, 07:01

Hi

My problem is, there are 2 zones running in the server, now, the requirement is there can be only 1 connection per user no matter what zone they try to login. For my setting, if a user logged in to the same zone they already connected, the previous session will be deleted, but the user can logged in to another zone anyway. Do the Smartfox can control something like this or I have to implement to check the user on my extension explicitly?

Regards,
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Can I set that only one user can login at a time for all zone?

Postby Lapo » 28 May 2019, 07:16

Hi,
SmartFoxServer treats each Zone as a different game in the server, therefore it doesn't apply limitations to users being connected in multiple Zones at once. Sometimes this is actually useful for certain type of applications.

Also the concept of "same user" in SmartFoxServer does not exist out of the box. What I mean by this is that the default login system in SFS2X allows any user to be logged in, provided they each use a different user name. This means a client could be connected multiple times with different names.

To implement your use case you need to handle the server side SFSEvent.LOGIN event and add your own logic to it. In this case I would recommend using a database to store credentials and also to track the current session, so that if User "Lapo" is already logged in Zone 1 you will be able to deny access to Zone 2 unless he disconnects from the previous one.

You will also need to listen for the USER_DISCONNECT and USER_LOGOUT events to catch when the user leaves the Zone.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
pop2518
Posts: 16
Joined: 10 Jan 2012, 11:23

Re: Can I set that only one user can login at a time for all zone?

Postby pop2518 » 28 May 2019, 09:19

Lapo wrote:Hi,
SmartFoxServer treats each Zone as a different game in the server, therefore it doesn't apply limitations to users being connected in multiple Zones at once. Sometimes this is actually useful for certain type of applications.

Also the concept of "same user" in SmartFoxServer does not exist out of the box. What I mean by this is that the default login system in SFS2X allows any user to be logged in, provided they each use a different user name. This means a client could be connected multiple times with different names.

To implement your use case you need to handle the server side SFSEvent.LOGIN event and add your own logic to it. In this case I would recommend using a database to store credentials and also to track the current session, so that if User "Lapo" is already logged in Zone 1 you will be able to deny access to Zone 2 unless he disconnects from the previous one.

You will also need to listen for the USER_DISCONNECT and USER_LOGOUT events to catch when the user leaves the Zone.

Hope it helps


Ok, I got it, thanks a lot.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Stevenor and 95 guests