Username as an identifier

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

Post Reply
vtween
Posts: 36
Joined: 26 Jul 2007, 17:31

Username as an identifier

Post by vtween »

Hi,

In my VW implemetation, the user data is persistant (DB) and I cannot permit 2 sessions of the same user updateding its records.

I have a problem where canLogin does not disconnects a user with the same username if it logs into another zone.
Apparntly the username is not unique on the server ...

I would have disconnected the user manully (scanning all zones and logging out the user by name) but I cannot find an java API gives all the active zones.

Can you help?

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

Post by Lapo »

I have a problem where canLogin does not disconnects a user with the same username if it logs into another zone.
User names are unique within the scope of a Zone.
So a user "Bart" can be present in both Zone A and Zone B.

Keep in mind that Zones represent different applications running separately.
Lapo
--
gotoAndPlay()
...addicted to flash games
vtween
Posts: 36
Joined: 26 Jul 2007, 17:31

Post by vtween »

Hi Lapo,

Thanks for the reply.

I understand the username scope in the server.
However I need to find a solution to my requirement.
I would have disconnected the user manully (scanning all zones and logging out the user by name) but I cannot find a java API gives all the active zones.
In the Admin tool all the zones are exposed, so I guess there is a way to traverse them.
Is there a java API exposing such traversal, or can you think of another solution to my problem?

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

Post by Lapo »

Zones are defined statically, so you should know which zones you are using.
Simply set a list of active zone names in your code, then you can get the related Zone object by calling:

Code: Select all

Zone z = SmartFoxServer.getInstance().getZone("the-name")
You can verify the presence of a user by calling

Code: Select all

User u = z.getUserByName("user-name")
It will return null if no user with that name is logged in that zone.
Lapo
--
gotoAndPlay()
...addicted to flash games
vtween
Posts: 36
Joined: 26 Jul 2007, 17:31

Post by vtween »

Thanks again Lapo,

I would like to insists a little further.
It is true that the zones are defined statically, however I would not like to change my application code each time I change the zone definition. It would lead to an error prone deployment.
Therefore it would ease me alot if I could get this data from the sfs without having to parse the config.xml on my own.

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

Post by Lapo »

No problem, I should have mentioned this as well but I forgot :oops:

Code: Select all

LinkedList<Zone> allTheZones = SmartFoxServer.getInstance().getAllZones()
Lapo
--
gotoAndPlay()
...addicted to flash games
vtween
Posts: 36
Joined: 26 Jul 2007, 17:31

Post by vtween »

Many thanks. :)
Post Reply