Internal Event :: userExit
Availability:
SmartFoxServer PRO 1.2.1
Event name:
userExit
Description:
This event is fired each time a user leaves room within
the current Zone.
The event is available for both Zone
Level and Room
Level extensions.
Zone Level extensions will receive the event when a user is
leaving any room in that zone, while Room Level extensions
will receive it only if the user is leaving that room.
NOTE: It is always reccomended to keep track of Users by
using their unique id. For example you can keep a local list of users with
their id as the key.
When
a client leaves a room or is disconnected you will always receive the userId
of the User that was lost, so it will be very easy to handle the event this
way.
Properties:
| name | description | type | |
| uid | The id of the user that left the room | java.lang.String (*) | |
| oldPlayerIndex | The playerIndex the user was assigned in the room that was left (-1 = if he was a spectator) | java.lang.String (*) | |
| room | The Room object of the room that was left | object | |
| user | The User object (since 1.5.9) | object |
(*) A note on data types: the parameters passed by the server events to the running extensions are all Java types.
You can use them transparently in Actionscript or cast them to AS native data types.
» javadoc for -> java.lang.String
Example:
// Handle server events
// We assume this is a Room Level extension
function handleInternalEvent(evtObj)
{
if (evtObj.name == "userExit")
{
var uid = evtObj.userId
// Get the user from the local list
var user = myLocalUserList[uid]
trace("User: " + u.getName() + "left the room")
// Remove the user from the local list
delete myLocalUserList[uid]
}
}
See also: