UserManager doesn't update users after leave/join room

Post here your questions about the Flash / Flex / Air API for SFS2X

Moderators: Lapo, Bax

styx
Posts: 68
Joined: 13 May 2010, 19:41
Location: Poland

UserManager doesn't update users after leave/join room

Postby styx » 14 Nov 2014, 11:43

I use SmartFoxServer 2X 2.9.2 and Flash Api version 1.2.5

In sending private messages I use code from documentation:

Code: Select all

   sfs.send(new PrivateMessageRequest(message, sfs.userManager.getUserByName(login.toLowerCase()).id));


if the user leaves the room and comes back, userManager doesn't update his data, and i have error when sending message

Code: Select all

11:43:59,859 WARN  [SFSWorker:Sys:1] v290.SystemReqController     - java.lang.IllegalArgumentException: Private Message recipient is not available. Recipient ID: 3


Room Settings:

Code: Select all

  <room>
      <name>Glowny</name>
      <groupId>fotka</groupId>
      <password></password>
      <maxUsers>500</maxUsers>
      <maxSpectators>0</maxSpectators>
      <isDynamic>false</isDynamic>
      <isGame>false</isGame>
      <isHidden>false</isHidden>
      <autoRemoveMode>DEFAULT</autoRemoveMode>
      <permissions>
        <flags>PUBLIC_MESSAGES</flags>
        <maxRoomVariablesAllowed>10</maxRoomVariablesAllowed>
      </permissions>
      <events>USER_ENTER_EVENT,USER_EXIT_EVENT,USER_COUNT_CHANGE_EVENT,USER_VARIABLES_UPDATE_EVENT</events>
      <badWordsFilter isActive="true"/>
      <roomVariables/>
      <extension>
        <name></name>
        <type>JAVA</type>
        <file></file>
        <propertiesFile></propertiesFile>
        <reloadMode>AUTO</reloadMode>
      </extension>
    </room>
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: UserManager doesn't update users after leave/join room

Postby Lapo » 14 Nov 2014, 14:57

If you're working inside a Room you should obtain the target User for the Private Message directly from the Room itself.

E.g.:

Code: Select all

var target:User = theRoom.getUserByName("theUserName")


Also, I am not sure about what you mean with the error you have reported.
The message is saying that the target User is not found in the system, therefore the User must have left the server, not just left the Room.

Can you clarify in a step-by-step fashion how this is supposed to happen?

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
styx
Posts: 68
Joined: 13 May 2010, 19:41
Location: Poland

Re: UserManager doesn't update users after leave/join room

Postby styx » 14 Nov 2014, 15:10

Hi Lapo,

The user left the system and come back again to the same room, but in other users in UsersManager still exists with the old ID - global object UsersManger doesn't update

This bug occurs only in AS3 API,In HTML5 working properly.
Also in:
var target:User = theRoom.getUserByName("theUserName")

works properly. But in my case i can't use your code, i must use object UsersManager


I used the same code over 2 years, and still work properly until the update server and api from 2.8.1 to 2.9.2
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: UserManager doesn't update users after leave/join room

Postby Lapo » 14 Nov 2014, 15:43

When you say you updated from 2.8.1 to 2.9.2 you mean you first installed the full SmartFoxServer 2X 2.9.0 right?
Because you can't apply patch 2.9.2 on a 2.8.x installation.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
styx
Posts: 68
Joined: 13 May 2010, 19:41
Location: Poland

Re: UserManager doesn't update users after leave/join room

Postby styx » 14 Nov 2014, 16:10

Yes Lapo,
I've done exactly as you wrote.

I did it for the windows version (my development environment). And when I tested this problem appeared.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: UserManager doesn't update users after leave/join room

Postby Lapo » 15 Nov 2014, 14:07

Thanks, I've seen the video.
However there seem some other information missing and I am not able to reproduce the problem.

Let's say User A and User B are connected to the server.
User A cannot see User B until he meets him in a Room. From that moment he has a local reference. So you can call

Code: Select all

sfs.userManager.getUserByName("User B")

and obtain the reference to that User which in turn can be used to send a message.

If User B disconnects the reference is removed and the same line of code will return null. If then User B reconnects again nothing changes, until A and B meet again in the same Room.

This has always been the logic for the client API since the first version of SFS2X and nothing has changed between version 2.8 and 2.9, I can guarantee.

There seem to be a missing element in the report.
Also in the video it's not very clear what really happens when the user goes away. Is the user disconnected?
After he reconnects is he joining the same Room as before? From the video it seems so.
Lapo

--

gotoAndPlay()

...addicted to flash games
styx
Posts: 68
Joined: 13 May 2010, 19:41
Location: Poland

Re: UserManager doesn't update users after leave/join room

Postby styx » 17 Nov 2014, 15:25

I more tested and this error occurs only in cases where user is connected to more than one room

User A join Room A
User B join Room A
User A join Room B
User B join Room B

Now we have 2 rooms with 2 user each one,
User A belongs to room A and B
User B belongs to room A and B

User A execute command:

Code: Select all

sfs.userManager.getUserByName("B").id // n.e. return 2


Now User B disconnect the server. This is equivalent to leaving all room.
User A execute command:

Code: Select all

sfs.userManager.getUserByName("B").id // n.e. return 2


I think the global object UserManager is not cleared after disconect if the user belongs to more than one room

What do you think Lapo?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: UserManager doesn't update users after leave/join room

Postby Lapo » 17 Nov 2014, 16:34

You may be right, we'll check the use case.

From a client logic perspective I think there are several workarounds.

Why does the client app searches for a User with name X if such use is not in the system?
When User X disconnects the first time all references like his name in the User List or the Chat Window should go away, right? So there should be no way for a client to be able to interact with a User that has disconnected.

If you need some sort of "presence" type service in your application you should probably use the BuddyList which provides specific features for monitoring online friends, their status and exchange messages.

thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
styx
Posts: 68
Joined: 13 May 2010, 19:41
Location: Poland

Re: UserManager doesn't update users after leave/join room

Postby styx » 17 Nov 2014, 17:17

Why does the client app searches for a User with name X if such use is not in the system?
When User X disconnects the first time all references like his name in the User List or the Chat Window should go away, right? So there should be no way for a client to be able to interact with a User that has disconnected.

Lapo You're right, but I wanted to show you how to generate an error.
Because the problem is not in disconnect, but in reconnect to the room. If the user connected again to the same room, and for other users still have old data like ID, is a big error.

If you need some sort of "presence" type service in your application you should probably use the BuddyList which provides specific features for monitoring online friends, their status and exchange messages.

Yes buddylist is exactly what I need,
But chat on my site is only a small part. I have 2.5 million users and I would have to implement own logic relationships. Also I think that it would be too difficult to synchronize data from mysql to buddylist files.
And if every logon, I'll be created buddylist it will be sub-optimal, because some users have 200-400 friends, and some people never use chat


I am using multi-rooms to show who is in my "region." This is something like the type of geolocation (I saw something like this in the MMO room)
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: UserManager doesn't update users after leave/join room

Postby Lapo » 17 Nov 2014, 18:08

styx wrote:Lapo You're right, but I wanted to show you how to generate an error.

Thanks, that will help.

Because the problem is not in disconnect, but in reconnect to the room. If the user connected again to the same room, and for other users still have old data like ID, is a big error.

When the User connects again you will need to refresh whatever reference you were keeping before (e.g. visual user list etc...)
It's not correct to hold on to the previous ID, etc...

By the time the user has connected a second time and has entered the Room you are in, the UserManager will no longer return the previous object because it has been overwritten.


If you need some sort of "presence" type service in your application you should probably use the BuddyList which provides specific features for monitoring online friends, their status and exchange messages.

Yes buddylist is exactly what I need,
But chat on my site is only a small part. I have 2.5 million users and I would have to implement own logic relationships. Also I think that it would be too difficult to synchronize data from mysql to buddylist files.[/quote]
I am not sure about what you mean by that... You can create a custom storage class for the BuddyList that works with your DB instead of local files, if this is what you're asking.


And if every logon, I'll be created buddylist it will be sub-optimal, because some users have 200-400 friends, and some people never use chat

I don't follow your reasoning.
The buddylist system can be used even with a very high amount of CCU. In fact it has been tested with over 120K CCU, which is a pretty intense load and there's no specific problem or "sub-optimal" issues to worry about.
Lapo

--

gotoAndPlay()

...addicted to flash games
styx
Posts: 68
Joined: 13 May 2010, 19:41
Location: Poland

Re: UserManager doesn't update users after leave/join room

Postby styx » 20 Nov 2014, 12:33

By the time the user has connected a second time and has entered the Room you are in, the UserManager will no longer return the previous object because it has been overwritten.

In my case it's not. UserManager (when user belongs to more than one room) is not cleared after disconnect, and is not overwritten after entered room.

Thanks Lapo for the detailed advice, it is possible that soon I would use them.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: UserManager doesn't update users after leave/join room

Postby Lapo » 20 Nov 2014, 18:37

We done a more in depth analysis of your use case and found the cause for the problem you're seeing and the fact that the User reference is still present in the UserManager after leaving the server.

We should be able to fix it pretty quickly and send you an update to test. Ideally early next week.

Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: UserManager doesn't update users after leave/join room

Postby Lapo » 27 Nov 2014, 17:46

UPDATE: we have an update that fixes the problem.

Before doing an official release I'd like you to try it in your project to make sure it works fine. Drop us an email to our support@... email box and I'll send the updated library. Also add a link to this discussion in the mail.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
styx
Posts: 68
Joined: 13 May 2010, 19:41
Location: Poland

Re: UserManager doesn't update users after leave/join room

Postby styx » 28 Nov 2014, 13:01

Thx Lapo

I sent email.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: UserManager doesn't update users after leave/join room

Postby Lapo » 01 Dec 2014, 13:49

We sent the update last week, did you get it?
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X ActionScript 3 API”

Who is online

Users browsing this forum: No registered users and 20 guests