Possible UserVariable Bug

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

Moderators: Lapo, Bax

stix
Posts: 9
Joined: 01 May 2010, 15:51

Possible UserVariable Bug

Postby stix » 23 Dec 2010, 03:06

I've written an app that uses UserVariables to store user data. The first UserVariable is set before joining any room and works great - all users see that the user has the variable.

When one user creates a game room and sets two more UserVariables in the game room - they seem to work OK. They exist in the admin tool and the user receives a USER_VARIABLES_UPDATE event. However, when a second user joins that game room from the lobby and iterates through the existing users, the only UserVariable that exists for the first user is the UserVariable set before joining any rooms.

I know the UserVariables are there, since if a third user launches the app, joins the zone and enters that game room, the UserVariables appear for that same user when iterating the user list.

Does anyone have a reason that this would happen or is there is a bug in the client API (AS3)?
User avatar
Lapo
Site Admin
Posts: 21682
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 23 Dec 2010, 14:34

What SFS2X version and API version do you use. I am quite sure that this shouldn't happen in RC1a, and btw we just released RC1b yesterday (check the home page)

Your API should be at least 0.9.4 or later (0.9.8 most recent)
Lapo
--
gotoAndPlay()
...addicted to flash games
stix
Posts: 9
Joined: 01 May 2010, 15:51

Postby stix » 23 Dec 2010, 15:37

I suspected the same thing. So before posting, I upgraded the server to RC1b and updated the client to 0.9.8, but same results.

I've "cleaned" the project, rebooted the server etc.
User avatar
Lapo
Site Admin
Posts: 21682
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 23 Dec 2010, 17:27

Can you please send us the debug output of the client that doesn't get the variables? Run it in the Flash IDE with the SmartFox.debug flag turned on and send us the transcript via email, we'll take a look after the Xmas pause.
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
copet80
Posts: 42
Joined: 27 Apr 2010, 22:23
Location: Australia
Contact:

Postby copet80 » 31 Jan 2011, 01:17

Hi Lapo, stix, is there any update to this issue? I'm getting a similar issue with my development. In my case, it happens like this:

1. Player A joins Room 1
2. Player B joins Room 1
3. Player A joins Room 2
4. Player B joins Room 2
5. Player B joins Room 1 and moves to (100, 100)
6. Player A joins Room 1

... but player A still thinks player B is on the previous coordinate. From this point onwards, it seems that whatever Player B sets as user variable doesn't get updated in Player A BEFORE Player A joins Room 1.

One thing that I noticed is that the coordinate is changed when inspected from the admin panel, but using the User.getVariable("x") shows that the value hasn't been updated.

Is this a known issue?
User avatar
copet80
Posts: 42
Joined: 27 Apr 2010, 22:23
Location: Australia
Contact:

Postby copet80 » 31 Jan 2011, 02:25

On closer inspection, I can really confirm that the user variables on other rooms don't get saved, or at least sent with the correct values (upon joining that room) in all of the following methods:

(a) room.userList
(b) user.getVariables()
(c) user.getVariable()
(d) SmartFox.userManager.getUserList()

... even though the admin reports the correct values.

I also tried adding a keyboard shortcut that would trace the user list using SmartFox.userManager.getUserList() from the point of view of Player A and noticed the following:

1. Player A joins Room 1 - (d) returns 1 user
2. Player B joins Room 1 - (d) returns 2 users
3. Player B joins Room 2 - (d) returns 1 user

So far so good, but this is where the issue appears:
1. Player A joins Room 1 - (d) returns 1 user
2. Player B joins Room 1 - (d) returns 2 users
3. Player A joins Room 2 - (d) returns 2 users (what???)

Can someone please advise?
User avatar
Lapo
Site Admin
Posts: 21682
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 31 Jan 2011, 12:54

Thanks for the detail. We'll take a look and let you know as quick as possible.
Lapo

--

gotoAndPlay()

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

Postby Lapo » 31 Jan 2011, 14:23

Ah, by the way, can you please confirm that you are using SFS2X RC1b and the latest client API provided with it?

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
copet80
Posts: 42
Joined: 27 Apr 2010, 22:23
Location: Australia
Contact:

Postby copet80 » 31 Jan 2011, 20:01

Thanks for the reply, Lapo. Yes I am using the RC1b and the latest client.
User avatar
copet80
Posts: 42
Joined: 27 Apr 2010, 22:23
Location: Australia
Contact:

Postby copet80 » 03 Feb 2011, 04:58

Hi Lapo, I'm just wondering if there's any news on this?

Thanks in advance!
User avatar
Lapo
Site Admin
Posts: 21682
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 03 Feb 2011, 08:18

We need a clarification here:
1. Player A joins Room 1
2. Player B joins Room 1
3. Player A joins Room 2
4. Player B joins Room 2
5. Player B joins Room 1 and moves to (100, 100)
6. Player A joins Room 1

At #5 Player B joins Room1, but he has already done that in #2. Which one is correct?

EDIT: Sorry, maybe I've interpreted this wrongly. You mean that when B joins Room2 he leaves Room1
Lapo

--

gotoAndPlay()

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

Postby Lapo » 03 Feb 2011, 09:39

We did a series of brief tests but we don't see any problems when switching rooms. Variables are transmitted and received correctly. Additionally UserVariables are Room-agnostic, they don't depend on the Room in which you are in (in fact you can update your vars even outside of any Room).

As regards the main userManager we can reproduce that. I am not sure if it's a real bug at the moment. The global user manager works slightly differently than the Room's user manager (and it's not even particularly useful for the developer)
Typically you will always access the user lists via the Room objects, grabbing the room list from there.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
copet80
Posts: 42
Joined: 27 Apr 2010, 22:23
Location: Australia
Contact:

Postby copet80 » 04 Feb 2011, 04:42

Hi Lapo,

I can see your point, but I can still confirm that the user variables don't get updated when retrieving the userList from the room parameter upon joining that room.

To illustrate the problem, I've developed a simple Flex app that will show you how user variables don't get updated. You can download the ZIP file from here:
https://www.yousendit.com/download/MzZH ... NEpFQlE9PQ
(sorry it's 2.6MB as it includes spark, etc.)

Just run the UserVariableTest.swf under the bin-debug folder twice to simulate two players. Then follow these steps:

1. Player 1 (1st window) joins Room_A
2. Player 2 (2nd window) joins Room_A
3. Player 2 joins Room_B (note: on Player 1 window, the userManager.getUserList() list only shows Player 1)
3. On Player 2 window, select Player 2 (0, 0) <<< ME and change the x or y values and press Update
4. Player 1 joins Room_B
5. You'll see that on Player 1 window, Player 2 has the right coordinate

Now this is where the problem happens:
6. Player 1 joins Room_A
7. Player 2 joins Room_A
8. Player 2 joins Room_B (note: on Player 1 window, the userManager.getUserList() list shows both Player 1 and Player 2)
9. On Player 2 window, select Player 2 (0, 0) <<< ME (if it's not already selected) and change the x or y values and press Update
10. Player 1 joins Room_B
11. Now you'll notice that on Player 1 window Player 2 still have the old coordinates

Having the user variables updated on join room is an important logic in our game, because we need to determine the latest position of each players already on the new room. I'm sure everyone shares this same logic in their applications. So my question is whether this is a known bug that is already picked up and being worked on, or am I doing something really wrong here?

I've included the complete source for the Flex app in case you want to have a look at my implementation.
User avatar
Lapo
Site Admin
Posts: 21682
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 04 Feb 2011, 12:37

Thanks for the details and the example. I'll add them as an attachment to our bug tracker ticket.
I will keep you updated. If possible we'll provide a nightly build with the fix, if the problem is found.
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
copet80
Posts: 42
Joined: 27 Apr 2010, 22:23
Location: Australia
Contact:

Postby copet80 » 06 Feb 2011, 20:45

Hi Lapo. Thanks for looking into this. I'll look forward to further news on this.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 38 guests