Page 1 of 1

Username as an identifier

Posted: 09 Nov 2008, 08:15
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.

Posted: 09 Nov 2008, 14:58
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.

Posted: 10 Nov 2008, 05:31
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

Posted: 10 Nov 2008, 10:02
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.

Posted: 10 Nov 2008, 10:11
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

Posted: 10 Nov 2008, 10:41
by Lapo
No problem, I should have mentioned this as well but I forgot :oops:

Code: Select all

LinkedList<Zone> allTheZones = SmartFoxServer.getInstance().getAllZones()

Posted: 10 Nov 2008, 10:46
by vtween
Many thanks. :)