SFSEvent

Kind of class:public class
Package:com.smartfoxserver.v2.core
Inherits from:BaseEvent < Event
Classpath:com.smartfoxserver.v2.core.SFSEvent
File last modified:Thursday, 12 August 2010, 15:44:56
This is the main SmartFox Event class. All major system events are found here.
See also:

Summary


Constructor
Constants
  • UDP_INIT : String
    • The Event notifies the result of the initial UDP handshake.
  • CONNECTION : String
    • The Event notifies the result of a connection attempt.
  • CONNECTION_LOST : String
    • The Event notifies the disconnection from the Server.
  • CONNECTION_RETRY : String
    • The Event notifies a temporary disconnection from the Server followed by an immediate attempt to reconnect.
  • CONNECTION_RESUME : String
    • The Event is dispatched after a temporary disconnection, when the connection to the Server has been re-establisehd.
  • CONFIG_LOAD_SUCCESS : String
    • Dispatched when the external SmartFox configuration file has been loaded successfully.
  • CONFIG_LOAD_FAILURE : String
    • Dispatched when an error occurs while loading the external SmartFox configuration file.
  • LOGIN : String
    • The Event is dispatched in response to a login request.
  • LOGIN_ERROR : String
    • The Event is dispatched in response to a failed login request.
  • LOGOUT : String
    • The Event is dispatched in response to a logout request.
  • ROOM_ADD : String
    • The Event is dispatched when a new Room was created inside the Zone under any of the Room Groups that the User is listening for.
  • ROOM_REMOVE : String
    • The Event is dispatched whenever a Room is removed from the Zone, under any of the Room Groups that the User is listening for.
  • ROOM_CREATION_ERROR : String
    • The Event is dispatched in response to a failed create room request.
  • ROOM_JOIN : String
    • The Event is dispatched in response to a JoinRoomRequest.
  • ROOM_JOIN_ERROR : String
    • The Event is dispatched in response to a failed JoinRoomRequest.
  • USER_ENTER_ROOM : String
    • The Event is fired whenever a User enters one of the Rooms where the current User is joined.
  • USER_EXIT_ROOM : String
    • The Event is fired whenever a User leaves one of the Rooms where the current User is joined.
  • USER_COUNT_CHANGE : String
    • The Event is fired whenever the number of users/spectators in a Room changes.
  • PUBLIC_MESSAGE : String
    • The Event is fired when a User sends a public message.
  • PRIVATE_MESSAGE : String
    • The Event is fired when a User receives a private message.
  • MODERATOR_MESSAGE : String
    • The Event is fired when a User receives a Moderator message.
  • ADMIN_MESSAGE : String
    • The Event is fired when a User receives an Admin message.
  • OBJECT_MESSAGE : String
    • This Event is received when a User has sent an ObjectMessage request
  • EXTENSION_RESPONSE : String
    • The Event is fired every time a server-side Extension sends a message, usually in response to an ExtensionRequest.
  • ROOM_VARIABLES_UPDATE : String
    • The Event is fired in response to a SetRoomVariablesRequest
  • USER_VARIABLES_UPDATE : String
    • The Event is fired in response to a SetUserVariablesRequest
  • ROOM_GROUP_SUBSCRIBE : String
    • The Event is fired in response to a SubscribeRoomGroupRequest
  • ROOM_GROUP_UNSUBSCRIBE : String
    • The Event is fired in response to an UnsubscribeRoomGroupRequest
  • ROOM_GROUP_SUBSCRIBE_ERROR : String
    • The Event is fired in response to a failed SubscribeRoomGroupRequest
  • ROOM_GROUP_UNSUBSCRIBE_ERROR : String
    • The Event is fired in response to a failed UnsubscribeRoomGroupRequest
  • SPECTATOR_TO_PLAYER : String
    • The Event is fired in response to a successful SpectatorToPlayerRequest
  • PLAYER_TO_SPECTATOR : String
    • The Event is fired in response to a successful PlayerToSpectatorRequest
  • SPECTATOR_TO_PLAYER_ERROR : String
    • The Event is fired in response to a failed SpectatorToPlayerRequest
  • PLAYER_TO_SPECTATOR_ERROR : String
    • The Event is fired in response to a failed PlayerToSpectatorRequest
  • ROOM_NAME_CHANGE : String
    • The Event is fired in response to a ChangeRoomNameRequest
  • ROOM_NAME_CHANGE_ERROR : String
    • The Event is fired in response to a failed ChangeRoomNameRequest
  • ROOM_PASSWORD_STATE_CHANGE : String
    • The Event is fired in response to a ChangeRoomPasswordStateRequest.
  • ROOM_PASSWORD_STATE_CHANGE_ERROR : String
    • The Event is fired in response to a failed ChangeRoomPasswordStateRequest
  • ROOM_CAPACITY_CHANGE : String
    • The Event is fired in response to a ChangeRoomCapacityRequest
  • ROOM_CAPACITY_CHANGE_ERROR : String
    • The Event is fired in response to a failed ChangeRoomCapacityRequest
  • ROOM_FIND_RESULT : String
    • The Event is fired in response to a FindRoomsRequest
  • USER_FIND_RESULT : String
    • The Event is fired in response to a FindUsersRequest
  • INVITATION : String
    • The Event is fired when another User has sent you an Invitation
  • INVITATION_REPLY : String
    • The Event is fired when a User sends a reply to your Invitation
  • INVITATION_REPLY_ERROR : String
    • The Event is fired in response to a failed InvitationReplyRequest
Instance properties
Instance properties inherited from BaseEvent
Instance methods
  • clone : Event
    • Get a copy of the current instance.
  • toString : String
    • Get a string containing all the properties of the current instance.
Instance methods inherited from BaseEvent

Constructor

SFSEvent

public function SFSEvent (
type:String, params:Object)

Constants

ADMIN_MESSAGE

public static const ADMIN_MESSAGE:String = "adminMessage"
(read)

The Event is fired when a User receives an Admin message.

The params object contains the following parameters.
Parameters:
sender :
(User) the sender of the message
message:
(String) the message
data :
(ISFSObject) an object with custom data
Example:
  • The following example shows how to handle the event
    smartFox.addEventListener(SFSEvent.ADMIN_MESSAGE, onAdminMessage)
    
    function onAdminMessage(evt:SFSEvent):void
    {
        trace("Admin says: " + evt.params.message)
    }
Version:
  • SFS2X

CONFIG_LOAD_FAILURE

public static const CONFIG_LOAD_FAILURE:String = "configLoadFailure"
(read)

Dispatched when an error occurs while loading the external SmartFox configuration file.
Typically this event is received when the configuration is not found or its not accessible (no read permissions)
Example:
  • The following example shows how to handle a potential error in configuration loading.
    smartFox.addEventListener(SFSEvent.CONFIG_LOAD_FAILURE, onConfigLoadFailure)
    smartFox.loadConfig("testEnvironmentConfig.xml")
    
    function onConfigLoadFailureHandler(evt:SFSEvent):void
    {
        trace("Failed loading config file.")
    }
Version:
  • SFS2X

CONFIG_LOAD_SUCCESS

public static const CONFIG_LOAD_SUCCESS:String = "configLoadSuccess"
(read)

Dispatched when the external SmartFox configuration file has been loaded successfully.
This event is dispatched only if the connectOnSuccess parameter of the SmartFox.loadConfig method is set to false; otherwise the connection is made and the related CONNECTION event is fired.

No parameters are provided.
Example:
  • The following example shows how to handle a successful configuration loading.
    smartFox.addEventListener(SFSEvent.CONFIG_LOAD_SUCCESS, onConfigLoadSuccess)
    smartFox.loadConfig("testEnvironmentConfig.xml", false)
    
    function onConfigLoadSuccessHandler(evt:SFSEvent):void
    {
        trace("Config file loaded, now connecting...")
        smartFox.connect(smartFox.currentIp, smartFox.currentPort)
    }
Version:
  • SFS2X

CONNECTION

public static const CONNECTION:String = "connection"
(read)

The Event notifies the result of a connection attempt.

The params object contains the following parameters.
Parameters:
success:
(Boolean) true if a connection was established, false otherwise.
Example:
  • The following example shows how to start a connection
    var smartFox:SmartFox = new SmartFox()
    smartFox.addEventListener(SFSEvent.CONNECTION, onConnection)
    
    function onConnection(evt:SFSEvent):void
    {
        if (evt.params.success)
            trace("Connection was established")
        else
            trace("Connection failed")
    }
Version:
  • SFS2X (2.0)

CONNECTION_LOST

public static const CONNECTION_LOST:String = "connectionLost"
(read)

The Event notifies the disconnection from the Server.
When possible the API will also provide a reason for the disconnection:
  • Idle: the connection was dropped because the User was inactive for too long
  • Manual: the User requested the disconnection
  • Kick: the connection was dropped because the User was kicked
  • Ban: the connection was dropped because the User was banned
  • Unknown: the connection was lost for reasons outside of the API (slow or bad connection, network problems etc...)
The params object contains the following parameters.
Parameters:
reason:
(String) the reason of the disconnection.
Example:
  • The following example shows how to handle a disconnection
    var smartFox:SmartFox = new SmartFox()
    smartFox.addEventListener(SFSEvent.CONNECTION_LOST, onConnectionLost)
    
    function onConnectionLost(evt:SFSEvent):void
    {
        trace("Connection was lost, Reason: " + evt.params.reason)
    }
Version:
  • SFS2X (2.0)

CONNECTION_RESUME

public static const CONNECTION_RESUME:String = "connectionResume"
(read)

The Event is dispatched after a temporary disconnection, when the connection to the Server has been re-establisehd.
SmartFoxServer 2X provides a powerful new feature that allows a broken connection to be re-established transparently
without loosing any of the current application state. This allows any player to get back in the game without fear of loosing
the match because of a sloppy internet connection or a sudden disconnection.

In case the re-connection attempts fails an CONNECTION_LOST event will be fired.
Example:
  • The following example shows how to handle a reconnection
    var smartFox:SmartFox = new SmartFox()
    smartFox.addEventListener(SFSEvent.CONNECTION_RETRY, onConnectionRetry)
    smartFox.addEventListener(SFSEvent.CONNECTION_RESUME, onConnectionResume)
    smartFox.addEventListener(SFSEvent.CONNECTION_LOST, onConnectionLost)
    
    function onConnectionRetry(evt:SFSEvent):void
    {
        // Freeze your GUI and provide some feedback to the Player
    }
    
    function onConnectionResume(evt:SFSEvent):void
    {
        // Unfreeze the GUI and let the player continue with the game...
    }
    
    function onConnectionLost(evt:SFSEvent):void
    {
        trace("Ouch, connection was lost. Reason: " + evt.params.reason)
    }
Version:
  • SFS2X

CONNECTION_RETRY

public static const CONNECTION_RETRY:String = "connectionRetry"
(read)

The Event notifies a temporary disconnection from the Server followed by an immediate attempt to reconnect.
SmartFoxServer 2X provides a powerful new feature that allows a broken connection to be re-established transparently
without loosing any of the current application state. This allows any player to get back in the game without fear of loosing
the match because of a sloppy internet connection.

When this event is dispatched the API enter a "freeze" mode where no new requests can be sent until the reconnection is
successfully performed. It is highly recommended to handle this event and freeze your application interface accordingly until the
CONNECTION_RESUME event is fired.
Example:
  • The following example shows how to handle a reconnection
    var smartFox:SmartFox = new SmartFox()
    smartFox.addEventListener(SFSEvent.CONNECTION_RETRY, onConnectionRetry)
    smartFox.addEventListener(SFSEvent.CONNECTION_RESUME, onConnectionResume)
    
    function onConnectionRetry(evt:SFSEvent):void
    {
        // Freeze your GUI and provide some feedback to the Player
    }
    
    function onConnectionResume(evt:SFSEvent):void
    {
        // Unfreeze the GUI and let the player continue with the game...
    }
Version:
  • SFS2X

EXTENSION_RESPONSE

public static const EXTENSION_RESPONSE:String = "extensionResponse"
(read)

The Event is fired every time a server-side Extension sends a message, usually in response to an ExtensionRequest.
(A server Extension can send messages at any moment, not just in response to a specific client request)

The params object contains the following parameters.
Parameters:
cmd :
(String) the name of the "command" (or "action id") associated with the message
params :
(ISFSObject) custom parameters
packetId:
(Number) (optional) the id of the packet for an UDP message, the id is an auto increment value sent by the server. It can be used to detect out of order UDP packets.
Version:
  • SFS2X

INVITATION

public static const INVITATION:String = "invitation"
(read)

The Event is fired when another User has sent you an Invitation

The params object contains the following parameters.
Parameters:
invitation:
(Invitation) the invitation object
Version:
  • SFS2X

INVITATION_REPLY

public static const INVITATION_REPLY:String = "invitationReply"
(read)

The Event is fired when a User sends a reply to your Invitation

The params object contains the following parameters.
Parameters:
invitee:
(User) the User that was invited
reply :
(int) the reply code. It can be either InvitationReply.ACCEPT or InvitationReply.REFUSE
data :
(ISFSObject) additional custom paramters (e.g. a reason for the refusal, a message etc...)
Version:
  • SFS2X

INVITATION_REPLY_ERROR

public static const INVITATION_REPLY_ERROR:String = "invitationReplyError"
(read)

The Event is fired in response to a failed InvitationReplyRequest
The failure is usually caused by a late reply which doesn't make it to the server within the expected time

The params object contains the following parameters.
Parameters:
errorMessage:
(String) the error message
Version:
  • SFS2X

LOGIN

public static const LOGIN:String = "login"
(read)

The Event is dispatched in response to a login request.

The params object contains the following parameters.
Parameters:
user:
(User) the User object
data:
(SFSObject) a custom object with extra params (if you have added custom server side logic)
Example:
  • The following example shows how to handle a login event
    smartFox.addEventListener(SFSEvent.LOGIN, onLogin)
    
    function onLogin(evt:SFSEvent):void
    {
        trace("Hi, I have just logged in as: " + evt.params.user.name)
    }
Version:
  • SFS2X

LOGIN_ERROR

public static const LOGIN_ERROR:String = "loginError"
(read)

The Event is dispatched in response to a failed login request.

The params object contains the following parameters.
Parameters:
errorMessage:
(String) the error message
Example:
  • The following example shows how to handle a login failure event
    smartFox.addEventListener(SFSEvent.LOGIN_ERROR, onLoginError)
    
    function onLoginError(evt:SFSEvent):void
    {
        trace("Login Failed. Reason: " + evt.params.errorMessage)
    }
See also:
Version:
  • SFS2X

LOGOUT

public static const LOGOUT:String = "logout"
(read)

The Event is dispatched in response to a logout request.
Usually this event needs to be handled when you want to logout from the current Zone and join another one.
In order to perform the operation correctly you need to do as follows:
  • Send a LogoutRequest to the Server
  • Handle the onLogout event on the client
  • Perform a new login in the new Zone
No parameters are passed for this event
Example:
  • The following example shows how to handle a logout event
    smartFox.addEventListener(SFSEvent.LOGOUT, onLogout)
    
    function onLogout(evt:SFSEvent):void
    {
        trace("Logout was successful")
        // Proceed with more logic here...
    }
Version:
  • SFS2X

MODERATOR_MESSAGE

public static const MODERATOR_MESSAGE:String = "moderatorMessage"
(read)

The Event is fired when a User receives a Moderator message.

The params object contains the following parameters.
Parameters:
sender :
(User) the sender of the message
message:
(String) the message
data :
(ISFSObject) an object with custom data
Example:
  • The following example shows how to handle the event
    smartFox.addEventListener(SFSEvent.MODERATOR_MESSAGE, onModeratorMessage)
    
    function onModeratorMessage(evt:SFSEvent):void
    {
        var sender:User = evt.params.sender as User
        trace("Moderator says: " + evt.params.message + ", from: " + sender)
    }
Version:
  • SFS2X

OBJECT_MESSAGE

public static const OBJECT_MESSAGE:String = "objectMessage"
(read)

This Event is received when a User has sent an ObjectMessage request
The object sent by the sender can contain custom data, such as a game move etc...

The params object contains the following parameters.
Parameters:
sender :
(User) the sender of the message
message:
(ISFSObject) the object data
Example:
  • The following example shows how to handle the event
    smartFox.addEventListener(SFSEvent.OBJECT_MESSAGE, onObjectMessage)
    
    function onObjectMessage(evt:SFSEvent):void
    {
        var obj:ISFSObject = evt.params.message as SFSObject
        // dumps the data object
        trace("Received data: " + obj.getDump())
    }
Version:
  • SFS2X

PLAYER_TO_SPECTATOR

public static const PLAYER_TO_SPECTATOR:String = "playerToSpectator"
(read)

The Event is fired in response to a successful PlayerToSpectatorRequest
Parameters:
room:
(Room) the Room where the player became a spectator
user:
(User) the User who became a spectator
Version:
  • SFS2X

PLAYER_TO_SPECTATOR_ERROR

public static const PLAYER_TO_SPECTATOR_ERROR:String = "playerToSpectatorError"
(read)

The Event is fired in response to a failed PlayerToSpectatorRequest

The params object contains the following parameters.
Parameters:
errorMessage:
(String) the error message
Version:
  • SFS2X

PRIVATE_MESSAGE

public static const PRIVATE_MESSAGE:String = "privateMessage"
(read)

The Event is fired when a User receives a private message.

The params object contains the following parameters.
Parameters:
sender :
(User) the sender of the message
message:
(String) the message
data :
(ISFSObject) an object with custom data
Example:
  • The following example shows how to handle the event
    smartFox.addEventListener(SFSEvent.PRIVATE_MESSAGE, onPrivateMessage)
    
    function onPrivateMessage(evt:SFSEvent):void
    {
        var sender:User = evt.params.sender as User
        trace("PM: " + evt.params.message + ", from: " + sender)
    }
Version:
  • SFS2X

PUBLIC_MESSAGE

public static const PUBLIC_MESSAGE:String = "publicMessage"
(read)

The Event is fired when a User sends a public message.
Also the User receives this event every time he sends a public message.

The params object contains the following parameters.
Parameters:
room :
(Room) the target Room
sender :
(User) the sender
message:
(String) the message
data :
(ISFSObject) an object with custom data
Example:
  • The following example shows how to handle the event
    smartFox.addEventListener(SFSEvent.PUBLIC_MESSAGE, onPublicMessage)
    
    function onPublicMessage(evt:SFSEvent):void
    {
        var sender:User = evt.params.sender as User
        trace(sender.name + ": " + evt.params.message)
    }
Version:
  • SFS2X

ROOM_ADD

public static const ROOM_ADD:String = "roomAdd"
(read)

The Event is dispatched when a new Room was created inside the Zone under any of the Room Groups that the User is listening for.

The params object contains the following parameters.
Parameters:
room:
(Room) the room object
Example:
  • The following example shows how to handle the event
    smartFox.addEventListener(SFSEvent.ROOM_ADD, onRoomAdd)
    
    function onRoomAdd(evt:SFSEvent):void
    {
        trace("A new Room was added: " + evt.params.room)
    }
Version:
  • SFS2X

ROOM_CAPACITY_CHANGE

public static const ROOM_CAPACITY_CHANGE:String = "roomCapacityChange"
(read)

The Event is fired in response to a ChangeRoomCapacityRequest

The params object contains the following parameters.
Parameters:
room:
(Room) the Room where the change occurred
Version:
  • SFS2X

ROOM_CAPACITY_CHANGE_ERROR

public static const ROOM_CAPACITY_CHANGE_ERROR:String = "roomCapacityChangeError"
(read)

The Event is fired in response to a failed ChangeRoomCapacityRequest

The params object contains the following parameters.
Parameters:
errorMessage:
(String) the error message
Version:
  • SFS2X

ROOM_CREATION_ERROR

public static const ROOM_CREATION_ERROR:String = "roomCreationError"
(read)

The Event is dispatched in response to a failed create room request.

The params object contains the following parameters.
Parameters:
errorMessage:
(String) the error message
Example:
  • The following example shows how to handle the event
    smartFox.addEventListener(SFSEvent.ROOM_CREATION_ERROR, onRoomCreationError)
    
    function onRoomCreationError(evt:SFSEvent):void
    {
        trace("Room Creation Error: " + evt.params.errorMessage)
    }
Version:
  • SFS2X

ROOM_FIND_RESULT

public static const ROOM_FIND_RESULT:String = "roomFindResult"
(read)

The Event is fired in response to a FindRoomsRequest

The params object contains the following parameters.
Parameters:
rooms:
(Array) a list of Rooms matching the request criteria. If no Room was found the list will be empty.
See also:
Version:
  • SFS2X

ROOM_GROUP_SUBSCRIBE

public static const ROOM_GROUP_SUBSCRIBE:String = "roomGroupSubscribe"
(read)

The Event is fired in response to a SubscribeRoomGroupRequest

The params object contains the following parameters.
Parameters:
groupId :
(String) the name of the group that was subscribed
newRooms:
(Array) the list of rooms contained in the new group
Version:
  • SFS2X

ROOM_GROUP_SUBSCRIBE_ERROR

public static const ROOM_GROUP_SUBSCRIBE_ERROR:String = "roomGroupSubscribeError"
(read)

The Event is fired in response to a failed SubscribeRoomGroupRequest

The params object contains the following parameters.
Parameters:
errorMessage:
(String) the error message
Version:
  • SFS2X

ROOM_GROUP_UNSUBSCRIBE

public static const ROOM_GROUP_UNSUBSCRIBE:String = "roomGroupUnsubscribe"
(read)

The Event is fired in response to an UnsubscribeRoomGroupRequest

The params object contains the following parameters.
Parameters:
groupId:
(String) the name of thr group that was unsubscribed
Version:
  • SFS2X

ROOM_GROUP_UNSUBSCRIBE_ERROR

public static const ROOM_GROUP_UNSUBSCRIBE_ERROR:String = "roomGroupUnsubscribeError"
(read)

The Event is fired in response to a failed UnsubscribeRoomGroupRequest

The params object contains the following parameters.
Parameters:
errorMessage:
(String) the error message
Version:
  • SFS2X

ROOM_JOIN

public static const ROOM_JOIN:String = "roomJoin"
(read)

The Event is dispatched in response to a JoinRoomRequest.

The params object contains the following parameters.
Parameters:
room:
(Room) the joined Room
Example:
  • The following example shows how to handle the event
    smartFox.addEventListener(SFSEvent.ROOM_JOIN, onRoomJoin)
    
    function onRoomJoin(evt:SFSEvent):void
    {
        var room:Room = evt.params.room
        trace("The Room " + room.name + " was succesfully joined!")
    }
Version:
  • SFS2X

ROOM_JOIN_ERROR

public static const ROOM_JOIN_ERROR:String = "roomJoinError"
(read)

The Event is dispatched in response to a failed JoinRoomRequest.

The params object contains the following parameters.
Parameters:
errorMessage:
(String) the error message
Example:
  • The following example shows how to handle the event
    smartFox.addEventListener(SFSEvent.ROOM_JOIN_ERROR, onRoomJoinError)
    
    function onRoomJoinError(evt:SFSEvent):void
    {
        trace("Join Room Failure: " + evt.params.errorMessage)
    }
Version:
  • SFS2X

ROOM_NAME_CHANGE

public static const ROOM_NAME_CHANGE:String = "roomNameChange"
(read)

The Event is fired in response to a ChangeRoomNameRequest

The params object contains the following parameters.
Parameters:
room :
(Room) the Room where the change occurred
oldName:
(String) the old Room name
Version:
  • SFS2X

ROOM_NAME_CHANGE_ERROR

public static const ROOM_NAME_CHANGE_ERROR:String = "roomNameChangeError"
(read)

The Event is fired in response to a failed ChangeRoomNameRequest

The params object contains the following parameters.
Parameters:
errorMessage:
(String) the error message
Version:
  • SFS2X

ROOM_PASSWORD_STATE_CHANGE

public static const ROOM_PASSWORD_STATE_CHANGE:String = "roomPasswordStateChange"
(read)

The Event is fired in response to a ChangeRoomPasswordStateRequest.
In particular this event when the password state is changed. For example when a non-password protected Room is assigned a password, or vice-versa

The params object contains the following parameters.
Parameters:
room:
(Room) the Room where the change occurred
Version:
  • SFS2X

ROOM_PASSWORD_STATE_CHANGE_ERROR

public static const ROOM_PASSWORD_STATE_CHANGE_ERROR:String = "roomPasswordStateChangeError"
(read)

The Event is fired in response to a failed ChangeRoomPasswordStateRequest

The params object contains the following parameters.
Parameters:
errorMessage:
(String) the error message
Version:
  • SFS2X

ROOM_REMOVE

public static const ROOM_REMOVE:String = "roomRemove"
(read)

The Event is dispatched whenever a Room is removed from the Zone, under any of the Room Groups that the User is listening for.

The params object contains the following parameters.
Parameters:
room:
(Room) the room object
Example:
  • The following example shows how to handle the event
    smartFox.addEventListener(SFSEvent.ROOM_REMOVE, onRoomRemove)
    
    function onRoomRemove(evt:SFSEvent):void
    {
        trace("A new Room was removed: " + evt.params.room)
    }
See also:
Version:
  • SFS2X

ROOM_VARIABLES_UPDATE

public static const ROOM_VARIABLES_UPDATE:String = "roomVariablesUpdate"
(read)

The Event is fired in response to a SetRoomVariablesRequest

The params object contains the following parameters.
Parameters:
room :
(Room) the Room in which the event occurred
changedVars:
(Array) the list of variable names that where modified or created
Version:
  • SFS2X

SPECTATOR_TO_PLAYER

public static const SPECTATOR_TO_PLAYER:String = "spectatorToPlayer"
(read)

The Event is fired in response to a successful SpectatorToPlayerRequest
Parameters:
room :
(Room) the Room where the spectator became a player
user :
(User) the User who became a player
playerId:
(int) the new playerId of the User
Version:
  • SFS2X

SPECTATOR_TO_PLAYER_ERROR

public static const SPECTATOR_TO_PLAYER_ERROR:String = "spectatorToPlayerError"
(read)

The Event is fired in response to a failed SpectatorToPlayerRequest

The params object contains the following parameters.
Parameters:
errorMessage:
(String) the error message
Version:
  • SFS2X

UDP_INIT

public static const UDP_INIT:String = "udpInit"
(read)

The Event notifies the result of the initial UDP handshake.
The handshake is sent in order to establish a channel of communication between client and server.

The params object contains the following parameters.
Parameters:
success:
(Boolean) true if a connection was established, false otherwise.
Example:
  • The following example shows how initialize the UDP channel

    smartFox.addEventListener(SFSEvent.UDP_INIT, onUDPInit)
    smartFox.initUDP(new AirUDPManager())
    
    private function onUDPInit(evt:SFSEvent):void
    {
        if (evt.params.success == false)
        {
            trace("Sorry, UDP is not available. Initialization failed")
        }
        else
        {
            // Init OK: Execute an extension call via UDP
            smartFox.send( new ExtensionRequest("udpTest", new SFSObject(), null, true) )
        }
    }
See also:
Version:
  • SFS2X (2.0)

USER_COUNT_CHANGE

public static const USER_COUNT_CHANGE:String = "userCountChange"
(read)

The Event is fired whenever the number of users/spectators in a Room changes.
The client receives updates for all Rooms inside the Room Groups that he is listening to.

The params object contains the following parameters.
Parameters:
room :
(Room) the Room
uCount:
(int) the new user count
sCount:
(int) the new spectator count
Example:
  • The following example shows how to handle the event
    smartFox.addEventListener(SFSEvent.USER_COUNT_CHANGE, onUserCountChange)
    
    function onUserCountChange(evt:SFSEvent):void
    {
        var room:Room = evt.params.room
        var uCount:int = evt.params.uCount
        var sCount:int = evt.params.sCount
    
        trace("Room: " + room.name + " contains " + uCount + " users and " + sCount + " spectators")
    }
Version:
  • SFS2X

USER_ENTER_ROOM

public static const USER_ENTER_ROOM:String = "userEnterRoom"
(read)

The Event is fired whenever a User enters one of the Rooms where the current User is joined.

The params object contains the following parameters.
Parameters:
user:
(User) the User object
room:
(Room) the Room object
Example:
  • The following example shows how to handle the event
    smartFox.addEventListener(SFSEvent.USER_ENTER_ROOM, onUserEnterRoom)
    
    function onUserEnterRoom(evt:SFSEvent):void
    {
        var room:Room = evt.params.room
        var user:User = evt.params.user
    
        trace("User: " + user.name + " has just joined Room: " + room.name)
    }
Version:
  • SFS2X

USER_EXIT_ROOM

public static const USER_EXIT_ROOM:String = "userExitRoom"
(read)

The Event is fired whenever a User leaves one of the Rooms where the current User is joined.

The params object contains the following parameters.
Parameters:
user:
(User) the User object
room:
(Room) the Room object
Example:
  • The following example shows how to handle the event
    smartFox.addEventListener(SFSEvent.USER_EXIT_ROOM, onUserExitRoom)
    
    function onUserExitRoom(evt:SFSEvent):void
    {
        var room:Room = evt.params.room
        var user:User = evt.params.user
    
        trace("User: " + user.name + " has just left Room: " + room.name)
    }
Version:
  • SFS2X

USER_FIND_RESULT

public static const USER_FIND_RESULT:String = "userFindResult"
(read)

The Event is fired in response to a FindUsersRequest

The params object contains the following parameters.
Parameters:
rooms:
(Array) a list of Users matching the request criteria. If no User was found the list will be empty.
See also:
Version:
  • SFS2X

USER_VARIABLES_UPDATE

public static const USER_VARIABLES_UPDATE:String = "userVariablesUpdate"
(read)

The Event is fired in response to a SetUserVariablesRequest

The params object contains the following parameters.
Parameters:
user :
(User) the User that created or modified the Variables
changedVars:
(Array) the list of variable names that where modified or created
Version:
  • SFS2X

Instance methods

clone

override public function clone (
) : Event

Get a copy of the current instance.
Returns:
  • a copy of the current instance.
Overrides:
  • Event.clone
Version:
  • SmartFoxServer

toString

override public function toString (
) : String

Get a string containing all the properties of the current instance.
Returns:
  • a string representation of the current instance.
Overrides:
  • Event.toString
Version:
  • SmartFoxServer