Page 1 of 1

onUserLeave() question

Posted: 14 Jun 2007, 02:18
by mr_malee
Ignore me

problem was i was trying to access a user object from params in the SFSEvent object

turns out the params back from a onUserLeaveRoom event are different than that of onUserEnterRoom

since i was accessing an undefined variable before populating my list it stopped the code from running.

Why are there so many different params for events?

like:
onUserCountChange

Dispatched when the user/spectator count of a room changed.

The params object contains the following parameters.

* room:Room - the Room object representing the room where the change occurred.

onUserEnterRoom

Dispatched when a user joins the current room.

The params object contains the following parameters.

* roomId:int - the id of the room joined by a user.
* user:User - the User object representing the user that joined the room.

onUserLeaveRoom

Dispatched when a user leaves the current room.

The params object contains the following parameters.

* roomId:int - the id of the room left by the user.
* userId:int - the id of the user that left the room (or got disconnected).
* userName:String - the name of the user.
shouldn't you just pass a room object and a user object?[/quote]

Posted: 14 Jun 2007, 08:36
by Lapo
in the case of the userLeaveRoom, the user object doesn't exist anymore when you get the event.
Since there are many asynchronous events going on we preferred to pass ids instead of objects in certain situations to avoid the risk of passing null references.
This could open an endless debate... but in the end this is the solution we preferred :)