Package | com.smartfoxserver.v2 |
Class | public class SmartFox |
Inheritance | SmartFox flash.events.EventDispatcher |
NOTE: in the provided examples, sfs
always indicates a SmartFox instance.
See also
Property | Defined By | ||
---|---|---|---|
buddyManager : IBuddyManager [read-only]
Returns a reference to the Buddy Manager. | SmartFox | ||
compressionThreshold : int [read-only]
Returns the current compression threshold. | SmartFox | ||
config : ConfigData [read-only]
Returns the client configuration details. | SmartFox | ||
connectionMode : String [read-only]
Returns the current connection mode after a connection has been successfully established. | SmartFox | ||
currentIp : String [read-only]
Returns the IP address of the SmartFoxServer 2X instance to which the client is connected. | SmartFox | ||
currentPort : int [read-only]
Returns the TCP port of the SmartFoxServer 2X instance to which the client is connected. | SmartFox | ||
currentZone : String [read-only]
Returns the Zone currently in use, if the user is already logged in. | SmartFox | ||
debug : Boolean
Indicates whether the client-server messages debug is enabled or not. | SmartFox | ||
httpUploadURI : String [read-only]
Returns the HTTP URI that can be used to upload files to SmartFoxServer 2X, using regular HTTP POST. | SmartFox | ||
isConnected : Boolean [read-only]
Indicates whether the client is connected to the server or not. | SmartFox | ||
joinedRooms : Array [read-only]
Returns a list of Room objects representing the Rooms currently joined by the client. | SmartFox | ||
lastJoinedRoom : Room
Returns the object representing the last Room joined by the client, if any. | SmartFox | ||
logger : Logger [read-only]
Returns a reference to the internal Logger instance used by SmartFoxServer 2X. | SmartFox | ||
maxMessageSize : int [read-only]
Returns the maximum size of messages allowed by the server. | SmartFox | ||
mySelf : User
Returns the User object representing the client when connected to a SmartFoxServer 2X instance. | SmartFox | ||
roomList : Array [read-only]
Returns a list of Room objects representing the Rooms currently "watched" by the client. | SmartFox | ||
roomManager : IRoomManager [read-only]
Returns a reference to the Room Manager. | SmartFox | ||
sessionToken : String [read-only]
Returns the unique session token of the client. | SmartFox | ||
udpAvailable : Boolean [read-only]
Indicates whether the UPD protocol is available or not in the current runtime. | SmartFox | ||
udpInited : Boolean [read-only]
Indicates whether the UDP handshake has been performed successfully or not. | SmartFox | ||
useBlueBox : Boolean
Indicates whether the client should attempt a tunnelled http connection through the BlueBox in case a socket connection can't be established. | SmartFox | ||
userManager : IUserManager [read-only]
Returns a reference to the User Manager. | SmartFox | ||
version : String [read-only]
Returns the current version of the SmartFoxServer 2X ActionScript 3 API. | SmartFox |
Method | Defined By | ||
---|---|---|---|
SmartFox(debug:Boolean = false)
Creates a new SmartFox instance. | SmartFox | ||
connect(host:String = null, port:int = -1):void
Establishes a connection between the client and a SmartFoxServer 2X instance. | SmartFox | ||
connectWithConfig(cfg:ConfigData):void
Establishes a connection between the client and a SmartFoxServer 2X instance. | SmartFox | ||
disconnect():void
Closes the connection between the client and the SmartFoxServer 2X instance. | SmartFox | ||
enableLagMonitor(enabled:Boolean, interval:int = 4, queueSize:int = 10):void
Enables the automatic realtime monitoring of the lag between the client and the server (round robin). | SmartFox | ||
getRoomById(id:int):Room
Retrieves a Room object from its id. | SmartFox | ||
getRoomByName(name:String):Room
Retrieves a Room object from its name. | SmartFox | ||
getRoomListFromGroup(groupId:String):Array
Retrieves the list of Rooms which are part of the specified Room Group. | SmartFox | ||
initCrypto():void
Initializes the connection cryptography. | SmartFox | ||
initUDP(manager:IUDPManager, udpHost:String = null, udpPort:int = -1):void
Initializes the UDP protocol by performing an handshake with the server. | SmartFox | ||
killConnection():void
Simulates an abrupt disconnection from the server. | SmartFox | ||
loadConfig(filePath:String = sfs-config.xml, connectOnSuccess:Boolean = true):void
Loads the client configuration file. | SmartFox | ||
send(request:IRequest):void
Sends a request to the server. | SmartFox | ||
setClientDetails(platformId:String, version:String):void
Allows to specify custom client details that will be used to gather statistics about the client platform via the AdminTool's Analytics Module. | SmartFox |
Event | Summary | Defined By | ||
---|---|---|---|---|
Dispatched when the current user receives a message from an administrator user. | SmartFox | |||
Dispatched when a buddy is added successfully to the current user's buddies list. | SmartFox | |||
Dispatched when a buddy is blocked or unblocked successfully by the current user. | SmartFox | |||
Dispatched if an error occurs while executing a request related to the Buddy List system. | SmartFox | |||
Dispatched if the Buddy List system is successfully initialized. | SmartFox | |||
Dispatched when a message from a buddy is received by the current user. | SmartFox | |||
Dispatched when a buddy in the current user's buddies list changes his online state in the Buddy List system. | SmartFox | |||
Dispatched when a buddy is removed successfully from the current user's buddies list. | SmartFox | |||
Dispatched when a buddy in the current user's buddies list updates one or more Buddy Variables. | SmartFox | |||
Dispatched if an error occurs while loading the external client configuration file. | SmartFox | |||
Dispatched when the external client configuration file is loaded successfully. | SmartFox | |||
Dispatched when a connection between the client and a SmartFoxServer 2X instance is attempted. | SmartFox | |||
Dispatched when the client cannot establish a socket connection to the server and the useBlueBox parameter is active in the configuration. | SmartFox | |||
Dispatched when the connection between the client and the SmartFoxServer 2X instance is interrupted. | SmartFox | |||
Dispatched when the connection between the client and the SmartFoxServer 2X instance is re-established after a temporary disconnection, while the SmartFoxServer 2X HRC system is available in the Zone. | SmartFox | |||
Dispatched when the connection between the client and the SmartFoxServer 2X instance is interrupted abruptly while the SmartFoxServer 2X HRC system is available in the Zone. | SmartFox | |||
Dispatched in return to the initialization of an encrypted connection. | SmartFox | |||
Dispatched when data coming from a server-side Extension is received by the current user. | SmartFox | |||
Dispatched when the current user receives an invitation from another user. | SmartFox | |||
Dispatched when the current user receives a reply to an invitation he sent previously. | SmartFox | |||
Dispatched when an error occurs while the current user is sending a reply to an invitation he received. | SmartFox | |||
Dispatched when the current user performs a successful login in a server Zone. | SmartFox | |||
Dispatched if an error occurs while the user login is being performed. | SmartFox | |||
Dispatched when the current user performs logs out of the server Zone. | SmartFox | |||
Dispatched when an MMOItem Variable is updated in an MMORoom. | SmartFox | |||
Dispatched when the current user receives a message from a moderator user. | SmartFox | |||
Dispatched when an object containing custom data is received by the current user. | SmartFox | |||
Dispatched when a new lag value measurement is available. | SmartFox | |||
Dispatched when a player is turned to a spectator inside a Game Room. | SmartFox | |||
Dispatched when an error occurs while the current user is being turned from player to spectator in a Game Room. | SmartFox | |||
Dispatched when a private message is received by the current user. | SmartFox | |||
Dispatched when one more users or one or more MMOItem objects enter/leave the current user's Area of Interest in MMORooms. | SmartFox | |||
Dispatched when a public message is received by the current user. | SmartFox | |||
Dispatched when a new Room is created inside the Zone under any of the Room Groups that the client subscribed. | SmartFox | |||
Dispatched when the capacity of a Room is changed. | SmartFox | |||
Dispatched when an error occurs while attempting to change the capacity of a Room. | SmartFox | |||
Dispatched if an error occurs while creating a new Room. | SmartFox | |||
Dispatched when a Rooms search is completed. | SmartFox | |||
Dispatched when a Group is subscribed by the current user. | SmartFox | |||
Dispatched when an error occurs while a Room Group is being subscribed. | SmartFox | |||
Dispatched when a Group is unsubscribed by the current user. | SmartFox | |||
Dispatched when an error occurs while a Room Group is being unsubscribed. | SmartFox | |||
Dispatched when a Room is joined by the current user. | SmartFox | |||
Dispatched when an error occurs while the current user is trying to join a Room. | SmartFox | |||
Dispatched when the name of a Room is changed. | SmartFox | |||
Dispatched when an error occurs while attempting to change the name of a Room. | SmartFox | |||
Dispatched when the password of a Room is set, changed or removed. | SmartFox | |||
Dispatched when an error occurs while attempting to set, change or remove the password of a Room. | SmartFox | |||
Dispatched when a Room belonging to one of the Groups subscribed by the client is removed from the Zone. | SmartFox | |||
Dispatched when a Room Variable is updated. | SmartFox | |||
Dispatched when a low level socket error is detected, for example bad/inconsistent data. | SmartFox | |||
Dispatched when a spectator is turned to a player inside a Game Room. | SmartFox | |||
Dispatched when an error occurs while the current user is being turned from spectator to player in a Game Room. | SmartFox | |||
Dispatched when the result of the UDP handshake is notified. | SmartFox | |||
Dispatched when the number of users/players or spectators inside a Room changes. | SmartFox | |||
Dispatched when one of the Rooms joined by the current user is entered by another user. | SmartFox | |||
Dispatched when one of the Rooms joined by the current user is left by another user, or by the current user himself. | SmartFox | |||
Dispatched when a users search is completed. | SmartFox | |||
Dispatched when a User Variable is updated. | SmartFox |
buddyManager | property |
buddyManager:IBuddyManager
[read-only] Returns a reference to the Buddy Manager. This manager is used internally by the SmartFoxServer 2X API; the reference returned by this property gives access to the buddies list, allowing interaction with Buddy and BuddyVariable objects and access to user properties in the Buddy List system.
public function get buddyManager():IBuddyManager
compressionThreshold | property |
compressionThreshold:int
[read-only] Returns the current compression threshold.
This value represents the maximum message size (in bytes) before the protocol compression is activated. It is determined by the server configuration.
public function get compressionThreshold():int
config | property |
config:ConfigData
[read-only]
Returns the client configuration details.
If the configuration hasn't been loaded yet, or passed to the connectWithConfig() method, a null
object is returned.
public function get config():ConfigData
See also
connectionMode | property |
connectionMode:String
[read-only] Returns the current connection mode after a connection has been successfully established. Possible values are defined as constants in the ConnectionMode class.
public function get connectionMode():String
See also
trace("Connection mode: ", sfs.connectionMode);
currentIp | property |
currentIp:String
[read-only] Returns the IP address of the SmartFoxServer 2X instance to which the client is connected.
public function get currentIp():String
See also
currentPort | property |
currentPort:int
[read-only] Returns the TCP port of the SmartFoxServer 2X instance to which the client is connected.
public function get currentPort():int
See also
currentZone | property |
currentZone:String
[read-only] Returns the Zone currently in use, if the user is already logged in.
public function get currentZone():String
See also
debug | property |
debug:Boolean
Indicates whether the client-server messages debug is enabled or not.
If set to true
, detailed debugging informations for all the incoming and outgoing messages are provided.
Debugging can be enabled when instantiating the SmartFox class too.
public function get debug():Boolean
public function set debug(value:Boolean):void
httpUploadURI | property |
httpUploadURI:String
[read-only] Returns the HTTP URI that can be used to upload files to SmartFoxServer 2X, using regular HTTP POST. For more details on how to use this functionality, see the Upload File tutorial.
NOTE: this property returns null
if no API configuration has been set or the current user is not already logged in the server.
public function get httpUploadURI():String
private var fileRef:FileReference = new FileReference(); private function someMethod():void { fileRef.addEventListener(Event.SELECT, onFileRefSelect); fileRef.addEventListener(Event.COMPLETE, onFileRefComplete); } private function onFileRefSelect(evt:Event):void { trace("File selected: " + fileRef.name); var req:URLRequest = new URLRequest(sfs.httpUploadURI); req.method = URLRequestMethod.POST; fileRef.upload(req); } private function onFileRefComplete(evt:Event):void { trace("Upload completed!") }
isConnected | property |
isConnected:Boolean
[read-only] Indicates whether the client is connected to the server or not.
public function get isConnected():Boolean
trace("Am I connected?", sfs.isConnected);
joinedRooms | property |
joinedRooms:Array
[read-only] Returns a list of Room objects representing the Rooms currently joined by the client.
NOTE: the same list is returned by the IRoomManager.getJoinedRooms() method, accessible through the roomManager getter; this was replicated on the SmartFox class for handy access due to its usually frequent usage.
public function get joinedRooms():Array
See also
lastJoinedRoom | property |
lastJoinedRoom:Room
Returns the object representing the last Room joined by the client, if any.
This property is null
if no Room was joined.
NOTE: setting the lastJoinedRoom property manually can disrupt the API functioning. Use the JoinRoomRequest request to join a new Room instead.
public function get lastJoinedRoom():Room
public function set lastJoinedRoom(value:Room):void
See also
logger | property |
logger:Logger
[read-only] Returns a reference to the internal Logger instance used by SmartFoxServer 2X.
public function get logger():Logger
maxMessageSize | property |
maxMessageSize:int
[read-only] Returns the maximum size of messages allowed by the server.
Any request exceeding this size will not be sent. The value is determined by the server configuration.
public function get maxMessageSize():int
mySelf | property |
mySelf:User
Returns the User object representing the client when connected to a SmartFoxServer 2X instance.
This object is generated upon successful login only, so it is null
if login was not performed yet.
NOTE: setting the mySelf property manually can disrupt the API functioning.
public function get mySelf():User
public function set mySelf(value:User):void
See also
roomList | property |
roomList:Array
[read-only] Returns a list of Room objects representing the Rooms currently "watched" by the client. The list contains all the Rooms that are currently joined and all the Rooms belonging to the Room Groups that have been subscribed.
NOTE 1: at login time, the client automatically subscribes all the Room Groups specified in the Zone's Default Room Groups setting.
NOTE 2: the same list is returned by the IRoomManager.getRoomList() method, accessible through the roomManager getter; this was replicated on the SmartFox class for handy access due to its usually frequent usage.
public function get roomList():Array
See also
roomManager | property |
roomManager:IRoomManager
[read-only] Returns a reference to the Room Manager. This manager is used internally by the SmartFoxServer 2X API; the reference returned by this property gives access to the Rooms list and Groups, allowing interaction with Room objects.
public function get roomManager():IRoomManager
sessionToken | property |
sessionToken:String
[read-only] Returns the unique session token of the client. The session token is a string sent by the server to the client after the initial handshake. It is required as mean of identification when uploading files to the server.
public function get sessionToken():String
See also
udpAvailable | property |
udpAvailable:Boolean
[read-only] Indicates whether the UPD protocol is available or not in the current runtime. UPD is available in a ActionScript 3 client if it is executed in the Adobe AIR 2.0 (or higher) runtime only.
Using the UDP protocol in an application requires that a handshake is performed between the client and the server. By default this is NOT done by the SmartFoxServer 2X API, to avoid allocating resources that might never be used. In order to activate the UDP support, the initUDP() method must be invoked explicitly.
public function get udpAvailable():Boolean
See also
udpInited | property |
udpInited:Boolean
[read-only] Indicates whether the UDP handshake has been performed successfully or not.
public function get udpInited():Boolean
See also
useBlueBox | property |
useBlueBox:Boolean
Indicates whether the client should attempt a tunnelled http connection through the BlueBox in case a socket connection can't be established.
NOTE: this property must be set before the connect() method is called. Also, after a connection is established, this property does not return the current connection mode (socket or http); for this purpose use the connectionMode property.
public function get useBlueBox():Boolean
public function set useBlueBox(value:Boolean):void
See also
userManager | property |
userManager:IUserManager
[read-only] Returns a reference to the User Manager. This manager is used internally by the SmartFoxServer 2X API; the reference returned by this property gives access to the users list, allowing interaction with User objects.
public function get userManager():IUserManager
version | property |
version:String
[read-only] Returns the current version of the SmartFoxServer 2X ActionScript 3 API.
public function get version():String
trace("Current API version:", sfs.version);
SmartFox | () | Constructor |
public function SmartFox(debug:Boolean = false)
Creates a new SmartFox instance.
Parametersdebug:Boolean (default = false ) — If true , the SmartFoxServer API debug messages are logged.
|
See also
var sfs:SmartFox = new SmartFox(true);
connect | () | method |
public function connect(host:String = null, port:int = -1):void
Establishes a connection between the client and a SmartFoxServer 2X instance. If no argument is passed, the client will use the settings loaded via loadConfig() method. In order to pass full connection settings without loading them from the external configuration file, use the connectWithConfig() method.
The client usually connects to a SmartFoxServer instance through a socket connection. In case a socket connection can't be established,
and the useBlueBox property is set to true
, a tunnelled http connection through the BlueBox module is attempted.
When a successful connection is established, the connectionMode property can be used to check the current connection mode.
Parameters
host:String (default = null ) — The address of the server to connect to.
| |
port:int (default = -1 ) — The TCP port to connect to.
|
ArgumentError — If an invalid host/address or port is passed, and it can't be found in the loaded settings.
|
See also
sfs.connect("127.0.0.1", 9933);
connectWithConfig | () | method |
public function connectWithConfig(cfg:ConfigData):void
Establishes a connection between the client and a SmartFoxServer 2X instance. The connection details (IP, port, etc) are contained in the passed object.
This is an alternative version of the connect() method. Read the method description for more informations.
Parameters
cfg:ConfigData — The configuration object.
|
See also
disconnect | () | method |
public function disconnect():void
Closes the connection between the client and the SmartFoxServer 2X instance.
See also
enableLagMonitor | () | method |
public function enableLagMonitor(enabled:Boolean, interval:int = 4, queueSize:int = 10):void
Enables the automatic realtime monitoring of the lag between the client and the server (round robin). When turned on, the SFSEvent.PING_PONG event type is dispatched continuously, providing the average of the last ten measured lag values. The lag monitoring is automatically halted when the user logs out of a Zone or gets disconnected.
NOTE: the lag monitoring can be enabled after the login has been performed successfully only.
Parameters
enabled:Boolean — The lag monitoring status: true to start the monitoring, false to stop it.
| |
interval:int (default = 4 ) — An optional amount of seconds to wait between each query (recommended 3-4s).
| |
queueSize:int (default = 10 ) — The amount of values stored temporarily and used to calculate the average lag.
|
See also
getRoomById | () | method |
public function getRoomById(id:int):Room
Retrieves a Room object from its id.
NOTE: the same object is returned by the IRoomManager.getRoomById() method, accessible through the roomManager getter; this was replicated on the SmartFox class for handy access due to its usually frequent usage.
Parameters
id:int — The id of the Room.
|
Room — An object representing the requested Room; null if no Room object with the passed id exists in the Rooms list.
|
See also
var roomId:int = 3; var room:Room = sfs.getRoomById(roomId); trace("The name of Room", roomId, "is", room.name);
getRoomByName | () | method |
public function getRoomByName(name:String):Room
Retrieves a Room object from its name.
NOTE: the same object is returned by the IRoomManager.getRoomByName() method, accessible through the roomManager getter; this was replicated on the SmartFox class for handy access due to its usually frequent usage.
Parameters
name:String — The name of the Room.
|
Room — An object representing the requested Room; null if no Room object with the passed name exists in the Rooms list.
|
See also
var roomName:String = "The Lobby"; var room:Room = sfs.getRoomByName(roomName); trace("The ID of Room '", roomName, "' is", room.id);
getRoomListFromGroup | () | method |
public function getRoomListFromGroup(groupId:String):Array
Retrieves the list of Rooms which are part of the specified Room Group.
NOTE: the same list is returned by the IRoomManager.getRoomListFromGroup() method, accessible through the roomManager getter; this was replicated on the SmartFox class for handy access due to its usually frequent usage.
Parameters
groupId:String — The name of the Group.
|
Array — The list of Room objects belonging to the passed Group.
|
See also
initCrypto | () | method |
public function initCrypto():void
Initializes the connection cryptography. Once this process is successfully completed all of the server's data will be encrypted using standard AES 128-bit algorithm, with a secure key served over HTTPS.
NOTE: this call must be executed right after a successful connection, before the login is performed.
See also
var sfs:SmartFox = new SmartFox(); sfs.addEventListener(SFSEvent.CONNECTION, onConnect); sfs.addEventListener(SFSEvent.CRYPTO_INIT, onCryptInit); sfs.connect("mysecuredomain.com", 9933); function onConnect(evt:SFSEvent):void { if (evt.param.success) sfs.initCrypto(); else trace("Sorry, connection failed"); } function onCryptInit(evt:SFSEvent):void { ta_data.text = evt.params.success; if (evt.params.success) sfs.send(new LoginRequest("MyName", "MyPassword", "MyZone")); else trace("Crypto init failed. Caused by: " + evt.params.errorMsg) }
initUDP | () | method |
public function initUDP(manager:IUDPManager, udpHost:String = null, udpPort:int = -1):void
Initializes the UDP protocol by performing an handshake with the server. In ActionScript 3, the UDP protocol is available exclusively if the client is executed in the Adobe AIR 2.0 (or higher) runtime. In order to properly activate the UDP support for the AIR runtime, an instance of the AirUDPManager class contained in the SmartFoxServer 2X ActionScript 3 API must be provided. Also, if udpHost or udpPort arguments are not passed, the client will use the settings loaded via loadConfig() method.
This method needs to be called only once. It can be executed at any moment provided that a connection to the server has already been established. After a successful initialization, UDP requests can be sent to the server-side Extension at any moment.
MTU note
The Maximum Transmission Unit (MTU), represents the largest amount of bytes that can be sent at once before packet fragmentation occurs. Since the UDP protocol uses a "nothing-or-all" approach to the transmission, it is important to keep in mind that, on average, a message size of 1100-1200 bytes is probably the maximum you can reach. If you exceed the MTU size the data will be "lost in hyperspace" (the Internet).
Another interesting matter is that there is no fixed size for the MTU, because each operating system uses a slightly different value. Because of this we suggest a conservative data size of 1000-1200 bytes per packet, to avoid packet loss. The SFS2X protocol compression allows to send 2-3KBytes of uncompressed data, which usually is squeezed down to a size of ~1000 bytes. If you have a larger amount of data to send, we suggest you to organize it in smaller chunks so that they don't exceed the suggested MTU size.
More details about the MTU can be found at the page linked below.
Parameters
manager:IUDPManager — An instance of the AirUDPManager class.
| |
udpHost:String (default = null ) — The IP address of the server to connect to.
| |
udpPort:int (default = -1 ) — The UDP port to connect to.
|
ArgumentError — If an invalid address or port is passed, and it can't be found in the loaded settings.
|
See also
private function someMethod():void { sfs.addEventListener(SFSEvent.UDP_INIT, onUDPInit); sfs.initUDP(new AirUDPManager()); } private function onUDPInit(evt:SFSEvent):void { if (evt.params.success) { // Connection successful: execute an Extension call via UDP sfs.send( new ExtensionRequest("udpTest", new SFSObject(), null, true) ); } else { trace("UDP initialization failed!"); } }
killConnection | () | method |
public function killConnection():void
Simulates an abrupt disconnection from the server. This method should be used for testing and simulations only, otherwise use the disconnect() method.
See also
loadConfig | () | method |
public function loadConfig(filePath:String = sfs-config.xml, connectOnSuccess:Boolean = true):void
Loads the client configuration file.
The SmartFox instance can be configured through an external XML configuration file loaded at run-time.
By default, the loadConfig() method loads a file named "sfs-config.xml", placed in the same folder of the application swf file.
If the connectOnSuccess argument is set to true
, on loading completion the connect() method is automatically called by the API,
otherwise the SFSEvent.CONFIG_LOAD_SUCCESS event type is dispatched. In case of loading error, the SFSEvent.CONFIG_LOAD_FAILURE event type id fired.
In order to pass full connection settings without loading them from the external configuration file, use the connectWithConfig() method.
The external XML configuration file has the following structure; ip, port and zone parameters are mandatory, all other parameters are optional:
<!-- SFS2X Client Configuration file --> <SmartFoxConfig> <ip>127.0.0.1</ip> <port>9933</port> <zone>SimpleChat</zone> <debug>true</debug> <udpIp>127.0.0.1</udpIp> <udpPort>9934</udpPort> <httpPort>8080</httpPort> <httpsPort>8443</httpsPort> <useBlueBox>true</useBlueBox> <forceBlueBoxOverHttps>false</forceBlueBoxOverHttps> <blueBoxPollingRate>500</blueBoxPollingRate> </SmartFoxConfig>
Parameters
filePath:String (default = sfs-config.xml ) — Filename of the external XML configuration, including its path relative to the folder of the application swf file.
| |
connectOnSuccess:Boolean (default = true ) — A flag indicating if the connection to SmartFoxServer must be attempted upon configuration loading completion.
|
See also
private function someMethod():void { var sfs:SmartFox = new SmartFox(); sfs.addEventListener(SFSEvent.CONFIG_LOAD_SUCCESS, onConfigLoaded); sfs.addEventListener(SFSEvent.CONFIG_LOAD_FAILURE, onConfigLoadFailed); sfs.loadConfig("testConfig.xml", false); } private function onConfigLoaded(evt:SFSEvent):void { // Configuration loaded successfully, now connect sfs.connect(); } private function onConfigLoadFailed(evt:SFSEvent):void { trace("Failed loading configuration file"); }
send | () | method |
public function send(request:IRequest):void
Sends a request to the server. All the available request objects can be found in the requests package.
Parameters
request:IRequest — A request object.
|
See also
sfs.send( new LoginRequest("KermitTheFrog", "KermitPass", "TheMuppetZone") );
sfs.send( new JoinRoomRequest("Lobby") );
var params:ISFSObject = new SFSObject(); params.putInt("x", 10); params.putInt("y", 37); sfs.send( new ExtensionRequest("setPosition", params) );
setClientDetails | () | method |
public function setClientDetails(platformId:String, version:String):void
Allows to specify custom client details that will be used to gather statistics about the client platform via the AdminTool's Analytics Module. By default the generic "Flash" label is used as platform, without specifying the version.
NOTE: this method must be called before the connection is started. The length of the two strings combined must be less than 512 characters.
Parameters
platformId:String — An identification string for the client runtime platform: for example "Flash PlugIn" or "iOS".
| |
version:String — An additional string to specify the version of the runtime platform: for example "2.0.0".
|
adminMessage | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.ADMIN_MESSAGE
Dispatched when the current user receives a message from an administrator user. This event is caused by the AdminMessageRequest request sent by a user with administration privileges.
The SFSEvent.ADMIN_MESSAGE constant defines the value of the type property of the event object for a adminMessage event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
sender | User | An object representing the administrator user who sent the message. |
message | String | The message sent by the administrator. |
data | ISFSObject | An object containing custom parameters which might accompany the message. |
See also
buddyAdd | Event |
com.smartfoxserver.v2.core.SFSBuddyEvent
com.smartfoxserver.v2.core.SFSBuddyEvent.BUDDY_ADD
Dispatched when a buddy is added successfully to the current user's buddies list. This event is fired in response to the AddBuddyRequest request in case the operation is executed successfully.
The SFSBuddyEvent.BUDDY_ADD constant defines the value of the type property of the event object for a buddyAdd event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
buddy | Buddy | The Buddy object corresponding to the buddy that was added. |
See also
buddyBlock | Event |
com.smartfoxserver.v2.core.SFSBuddyEvent
com.smartfoxserver.v2.core.SFSBuddyEvent.BUDDY_BLOCK
Dispatched when a buddy is blocked or unblocked successfully by the current user. This event is fired in response to the BlockBuddyRequest request in case the operation is executed successfully.
The SFSBuddyEvent.BUDDY_BLOCK constant defines the value of the type property of the event object for a buddyBlock event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
buddy | Buddy | The Buddy object corresponding to the buddy that was blocked/unblocked. |
See also
buddyError | Event |
com.smartfoxserver.v2.core.SFSBuddyEvent
com.smartfoxserver.v2.core.SFSBuddyEvent.BUDDY_ERROR
Dispatched if an error occurs while executing a request related to the Buddy List system. For example, this event is fired in response to the AddBuddyRequest request, the BlockBuddyRequest, etc.
The SFSBuddyEvent.BUDDY_ERROR constant defines the value of the type property of the event object for a buddyError event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
errorMessage | String | The message which describes the error. |
errorCode | int | The error code. |
buddyListInit | Event |
com.smartfoxserver.v2.core.SFSBuddyEvent
com.smartfoxserver.v2.core.SFSBuddyEvent.BUDDY_LIST_INIT
Dispatched if the Buddy List system is successfully initialized. This event is fired in response to the InitBuddyListRequest request in case the operation is executed successfully.
After the Buddy List system initialization, the user returns to his previous custom state (if any - see IBuddyManager.myState property). His online/offline state, his nickname and his persistent Buddy Variables are all loaded and broadcast in the system. In particular, the online state (see IBuddyManager.myOnlineState property) determines if the user will appear online or not to other users who have him in their buddies list.
The SFSBuddyEvent.BUDDY_LIST_INIT constant defines the value of the type property of the event object for a buddyListInit event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
buddyList | Array | A list of Buddy objects representing all the buddies in the current user's buddies list. |
myVariables | Array | A list of all the Buddy Variables associated with the current user. |
See also
buddyMessage | Event |
com.smartfoxserver.v2.core.SFSBuddyEvent
com.smartfoxserver.v2.core.SFSBuddyEvent.BUDDY_MESSAGE
Dispatched when a message from a buddy is received by the current user. This event is fired in response to the BuddyMessageRequest request.
NOTE: the same event is fired by the sender's client too, so that the user is aware that the message was delivered successfully to the recipient,
and it can be displayed in the chat area keeping the correct message ordering. As in this case the value of the buddy parameter is null
(because, being the sender, the user is not buddy to himself of course), there is no default way to know who the message was originally sent to.
As this information can be useful in scenarios where the sender is chatting with more than one buddy at the same time in separate windows or tabs
(and we need to write his own message in the proper one), the data parameter can be used to store, for example, the id of the recipient buddy.
The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
buddy | Buddy | The Buddy object representing the message sender. If the isItMe parameter is true , the value of this parameter is null (because a user is not buddy to himself). |
isItMe | Boolean | true if the message sender is the current user himself (in this case this event is a sort of message delivery confirmation). |
message | String | The message text. |
data | ISFSObject | An instance of SFSObject containing additional custom parameters (e.g. the message color, an emoticon id, etc). |
See also
buddyOnlineStateChange | Event |
com.smartfoxserver.v2.core.SFSBuddyEvent
com.smartfoxserver.v2.core.SFSBuddyEvent.BUDDY_ONLINE_STATE_UPDATE
Dispatched when a buddy in the current user's buddies list changes his online state in the Buddy List system. This event is fired in response to the GoOnlineRequest request.
NOTE: this event is dispatched to those who have the user as a buddy, but also to the user himself.
As in this case the value of the buddy parameter is null
(because the user is not buddy to himself of course),
the isItMe parameter should be used to check if the current user is the one who changed his own online state.
The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
buddy | Buddy | The Buddy object representing the buddy who changed his own online state. If the isItMe parameter is true , the value of this parameter is null (because a user is not buddy to himself). |
isItMe | Boolean | true if the online state was changed by the current user himself (in this case this event is a sort of state change confirmation). |
See also
buddyRemove | Event |
com.smartfoxserver.v2.core.SFSBuddyEvent
com.smartfoxserver.v2.core.SFSBuddyEvent.BUDDY_REMOVE
Dispatched when a buddy is removed successfully from the current user's buddies list. This event is fired in response to the RemoveBuddyRequest request in case the operation is executed successfully.
The SFSBuddyEvent.BUDDY_REMOVE constant defines the value of the type property of the event object for a buddyRemove event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
buddy | Buddy | The Buddy object corresponding to the buddy that was removed. |
See also
buddyVariablesUpdate | Event |
com.smartfoxserver.v2.core.SFSBuddyEvent
com.smartfoxserver.v2.core.SFSBuddyEvent.BUDDY_VARIABLES_UPDATE
Dispatched when a buddy in the current user's buddies list updates one or more Buddy Variables. This event is fired in response to the SetBuddyVariablesRequest request.
NOTE: this event is dispatched to those who have the user as a buddy, but also to the user himself.
As in this case the value of the buddy parameter is null
(because the user is not buddy to himself of course),
the isItMe parameter should be used to check if the current user is the one who updated his own Buddy Variables.
The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
buddy | Buddy | The Buddy object representing the buddy who updated his own Buddy Variables. If the isItMe parameter is true , the value of this parameter is null (because a user is not buddy to himself). |
isItMe | Boolean | true if the Buddy Variables were updated by the current user himself (in this case this event is a sort of update confirmation). |
changedVars | Array | The list of names of the Buddy Variables that were changed (or created for the first time). |
See also
configLoadFailure | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.CONFIG_LOAD_FAILURE
Dispatched if an error occurs while loading the external client configuration file. This event is fired in response to a call to the loadConfig() method, typically when the configuration file is not found or it isn't accessible (no read permissions).
The SFSEvent.CONFIG_LOAD_FAILURE constant defines the value of the type property of the event object for a configLoadFailure event.No parameters are available for this event object.
See also
configLoadSuccess | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.CONFIG_LOAD_SUCCESS
Dispatched when the external client configuration file is loaded successfully.
This event is fired in response to a call to the loadConfig() method,
but only if the connectOnSuccess argument of the loadConfig() method is set to false
;
otherwise the connection is attempted and the related SFSEvent.CONNECTION event type is fired.
No parameters are available for this event object.
See also
connection | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.CONNECTION
Dispatched when a connection between the client and a SmartFoxServer 2X instance is attempted. This event is fired in response to a call to the connect() method.
The SFSEvent.CONNECTION constant defines the value of the type property of the event object for a connection event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
success | Boolean | The connection result: true if a connection was established, false otherwise. |
See also
connectionAttemptHttp | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.CONNECTION_ATTEMPT_HTTP
Dispatched when the client cannot establish a socket connection to the server and the useBlueBox parameter is active in the configuration.
The event can be used to notify the user that a second connection attempt is running, using the BlueBox (HTTP tunnelling).
The SFSEvent.CONNECTION_ATTEMPT_HTTP constant defines the value of the type property of the event object for a connectionAttemptHttp event.No parameters are available for this event object.
connectionLost | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.CONNECTION_LOST
Dispatched when the connection between the client and the SmartFoxServer 2X instance is interrupted. This event is fired in response to a call to the disconnect() method.
The SFSEvent.CONNECTION_LOST constant defines the value of the type property of the event object for a connectionLost event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
reason | String | The reason of the disconnection, among those available in the ClientDisconnectionReason class. |
See also
connectionResume | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.CONNECTION_RESUME
Dispatched when the connection between the client and the SmartFoxServer 2X instance is re-established after a temporary disconnection, while the SmartFoxServer 2X HRC system is available in the Zone.
The HRC system allows a broken connection to be re-established transparently within a certain amount of time, without loosing any of the current application state. For example this allows any player to get back to a game without loosing the match because of a sloppy internet connection.
When this event is dispatched the application interface should be reverted to the state it had before the disconnection. In case the reconnection attempt fails, the connectionLost event is fired.
The SFSEvent.CONNECTION_RESUME constant defines the value of the type property of the event object for a connectionResume event.No parameters are available for this event object.
See also
connectionRetry | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.CONNECTION_RETRY
Dispatched when the connection between the client and the SmartFoxServer 2X instance is interrupted abruptly while the SmartFoxServer 2X HRC system is available in the Zone.
The HRC system allows a broken connection to be re-established transparently within a certain amount of time, without loosing any of the current application state. For example this allows any player to get back to a game without 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 the application interface accordingly until the connectionResume event is fired, or the reconnection fails and the user is definitely disconnected and the connectionLost event is fired.
The SFSEvent.CONNECTION_RETRY constant defines the value of the type property of the event object for a connectionRetry event.No parameters are available for this event object.
See also
cryptoInit | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.CRYPTO_INIT
Dispatched in return to the initialization of an encrypted connection. This event is fired in response to a call to the initCrypto() method.
The SFSEvent.CRYPTO_INIT constant defines the value of the type property of the event object for a cryptoInit call.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
success | Boolean | true if a unique encryption key was successfully retrieved via HTTPS, false if the transaction failed. |
errorMsg | String | If success is false , provides additional details on the occurred error. |
See also
extensionResponse | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.EXTENSION_RESPONSE
Dispatched when data coming from a server-side Extension is received by the current user. Data is usually sent by the server to one or more clients in response to an ExtensionRequest request, but not necessarily.
The SFSEvent.EXTENSION_RESPONSE constant defines the value of the type property of the event object for a extensionResponse event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
cmd | String | The name of the command which identifies an action that should be executed by the client. If this event is fired in response to a request sent by the client, it is a common practice to use the same command name passed to the request also in the response. |
params | ISFSObject | An object containing custom data sent by the Extension. |
sourceRoom | Number | [DEPRECATED - Use room property] The id of the Room which the Extension is attached to (for Room Extensions only). |
room | Room | An object representing the Room which the Extension is attached to (for Room Extensions only). |
packetId | Number | The id of the packet when the UDP protocol is used. As this is an auto-increment value generated by the server, it can be useful to detect UDP packets received in the wrong order. |
See also
invitation | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.INVITATION
Dispatched when the current user receives an invitation from another user. This event is caused by the InviteUsersRequest request; the user is supposed to reply using the InvitationReplyRequest request.
The SFSEvent.INVITATION constant defines the value of the type property of the event object for a invitation event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
invitation | Invitation | An object representing the invitation received by the current user. |
See also
invitationReply | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.INVITATION_REPLY
Dispatched when the current user receives a reply to an invitation he sent previously. This event is caused by the InvitationReplyRequest request sent by the invitee.
The SFSEvent.INVITATION_REPLY constant defines the value of the type property of the event object for a invitationReply event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
invitee | User | An object representing the user who replied to the invitation. |
reply | int | The answer to the invitation among those available as constants in the InvitationReply class. |
data | ISFSObject | An object containing custom parameters, for example a message describing the reason of refusal. |
See also
invitationReplyError | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.INVITATION_REPLY_ERROR
Dispatched when an error occurs while the current user is sending a reply to an invitation he received. This event is fired in response to the InvitationReplyRequest request in case the operation failed.
The SFSEvent.INVITATION_REPLY_ERROR constant defines the value of the type property of the event object for a invitationReplyError event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
errorMessage | String | A message containing the description of the error. |
errorCode | int | The error code. |
See also
login | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.LOGIN
Dispatched when the current user performs a successful login in a server Zone. This event is fired in response to the LoginRequest request.
The SFSEvent.LOGIN constant defines the value of the type property of the event object for a login event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
user | User | An object representing the user who performed the login. |
data | ISFSObject | An object containing custom parameters returned by a custom login system, if any. |
See also
loginError | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.LOGIN_ERROR
Dispatched if an error occurs while the user login is being performed. This event is fired in response to the LoginRequest request in case the operation failed.
The SFSEvent.LOGIN_ERROR constant defines the value of the type property of the event object for a loginError event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
errorMessage | String | A message containing the description of the error. |
errorCode | int | The error code. |
See also
logout | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.LOGOUT
Dispatched when the current user performs logs out of the server Zone. This event is fired in response to the LogoutRequest request.
The SFSEvent.LOGOUT constant defines the value of the type property of the event object for a logout event.No parameters are available for this event object.
See also
mmoItemVariablesUpdate | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.MMOITEM_VARIABLES_UPDATE
Dispatched when an MMOItem Variable is updated in an MMORoom. This event is caused by an MMOItem Variable being set, updated or deleted in a server side Extension, and it is received only if the current user has the related MMOItem in his Area of Interest.
The SFSEvent.MMOITEM_VARIABLES_UPDATE constant defines the value of the type property of the event object for a mmoItemVariablesUpdate event.The properties of the params object contained in the event have the following values:
Property | Type | Description |
---|---|---|
room | MMORoom | The MMORoom where the MMOItem whose Variables have been updated is located. |
mmoItem | MMOItem | The MMOItem whose variables have been updated. |
changedVars | Array | The list of names of the MMOItem Variables that were changed (or created for the first time). |
See also
moderatorMessage | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.MODERATOR_MESSAGE
Dispatched when the current user receives a message from a moderator user. This event can be caused by either the ModeratorMessageRequest, KickUserRequest or BanUserRequest requests sent by a user with at least moderation privileges. Also, this event can be caused by a kick/ban action performed through the SmartFoxServer 2X Administration Tool.
The SFSEvent.MODERATOR_MESSAGE constant defines the value of the type property of the event object for a moderatorMessage event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
sender | User | An object representing the moderator user who sent the message. |
message | String | The message sent by the moderator. |
data | ISFSObject | An object containing custom parameters which might accompany the message. |
See also
objectMessage | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.OBJECT_MESSAGE
Dispatched when an object containing custom data is received by the current user. This event is caused by an ObjectMessageRequest request sent by any user in the target Room.
The SFSEvent.OBJECT_MESSAGE constant defines the value of the type property of the event object for a objectMessage event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
sender | User | An object representing the user who sent the message. |
message | SFSObject | The content of the message: an object containing the custom parameters sent by the sender. |
See also
pingPong | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.PING_PONG
Dispatched when a new lag value measurement is available.
This event is fired when the automatic lag monitoring is turned on by passing true
to the enableLagMonitor() method.
The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
lagValue | int | The average of the last ten measured lag values, expressed in milliseconds. |
See also
playerToSpectator | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.PLAYER_TO_SPECTATOR
Dispatched when a player is turned to a spectator inside a Game Room. This event is fired in response to the PlayerToSpectatorRequest> request if the operation is executed successfully.
The SFSEvent.PLAYER_TO_SPECTATOR constant defines the value of the type property of the event object for a playerToSpectator event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
room | Room | An object representing the Room in which the player is turned to spectator. |
user | User | An object representing the player who was turned to spectator. |
See also
playerToSpectatorError | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.PLAYER_TO_SPECTATOR_ERROR
Dispatched when an error occurs while the current user is being turned from player to spectator in a Game Room. This event is fired in response to the PlayerToSpectatorRequest request in case the operation failed.
The SFSEvent.PLAYER_TO_SPECTATOR_ERROR constant defines the value of the type property of the event object for a playerToSpectatorError event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
errorMessage | String | A message containing the description of the error. |
errorCode | int | The error code. |
See also
privateMessage | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.PRIVATE_MESSAGE
Dispatched when a private message is received by the current user. This event is caused by a PrivateMessageRequest request sent by any user in the Zone.
NOTE: the same event is fired by the sender's client too, so that the user is aware that the message was delivered successfully to the recipient, and it can be displayed in the private chat area keeping the correct message ordering. In this case there is no default way to know who the message was originally sent to. As this information can be useful in scenarios where the sender is chatting privately with more than one user at the same time in separate windows or tabs (and we need to write his own message in the proper one), the data parameter can be used to store, for example, the id of the recipient user.
The SFSEvent.PRIVATE_MESSAGE constant defines the value of the type property of the event object for a privateMessage event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
sender | User | An object representing the user who sent the message. |
message | String | The message sent by the user. |
data | ISFSObject | An object containing custom parameters which might accompany the message. |
See also
proximityListUpdate | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.PROXIMITY_LIST_UPDATE
Dispatched when one more users or one or more MMOItem objects enter/leave the current user's Area of Interest in MMORooms. This event is fired after an MMORoom is joined and the SetUserPositionRequest request is sent at least one time.
NOTE: this event substitutes the default SFSEvent.USER_ENTER_ROOM and SFSEvent.USER_EXIT_ROOM events available in regular Rooms.
The SFSEvent.PROXIMITY_LIST_UPDATE constant defines the value of the type property of the event object for a proximityListUpdate event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
room | Room | The Room in which the event occurred. |
addedUsers | Array | A list of User objects representing the users who entered the current user's Area of Interest. |
removedUsers | Array | A list of User objects representing the users who left the current user's Area of Interest. |
addedItems | Array | A list of MMOItem objects which entered the current user's Area of Interest. |
removedItems | Array | A list of MMOItem objects which left the current user's Area of Interest. |
See also
publicMessage | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.PUBLIC_MESSAGE
Dispatched when a public message is received by the current user. This event is caused by a PublicMessageRequest request sent by any user in the target Room, including the current user himself.
The SFSEvent.PUBLIC_MESSAGE constant defines the value of the type property of the event object for a publicMessage event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
room | Room | An object representing the Room at which the message is targeted. |
sender | User | An object representing the user who sent the message. |
message | String | The message sent by the user. |
data | ISFSObject | An object containing custom parameters which might accompany the message. |
See also
roomAdd | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.ROOM_ADD
Dispatched when a new Room is created inside the Zone under any of the Room Groups that the client subscribed. This event is fired in response to the CreateRoomRequest and CreateSFSGameRequest requests in case the operation is executed successfully.
The SFSEvent.ROOM_ADD constant defines the value of the type property of the event object for a roomAdd event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
room | Room | An object representing the Room that was created. |
See also
roomCapacityChange | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.ROOM_CAPACITY_CHANGE
Dispatched when the capacity of a Room is changed. This event is fired in response to the ChangeRoomCapacityRequest request if the operation is executed successfully.
The SFSEvent.ROOM_CAPACITY_CHANGE constant defines the value of the type property of the event object for a roomCapacityChange event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
room | Room | An object representing the Room whose capacity was changed. |
See also
roomCapacityChangeError | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.ROOM_CAPACITY_CHANGE_ERROR
Dispatched when an error occurs while attempting to change the capacity of a Room. This event is fired in response to the ChangeRoomCapacityRequest request in case the operation failed.
The SFSEvent.ROOM_CAPACITY_CHANGE_ERROR constant defines the value of the type property of the event object for a roomCapacityChangeError event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
errorMessage | String | A message containing the description of the error. |
errorCode | int | The error code. |
See also
roomCreationError | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.ROOM_CREATION_ERROR
Dispatched if an error occurs while creating a new Room. This event is fired in response to the CreateRoomRequest and CreateSFSGameRequest requests in case the operation failed.
The SFSEvent.ROOM_CREATION_ERROR constant defines the value of the type property of the event object for a roomCreationError event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
errorMessage | String | A message containing the description of the error. |
errorCode | int | The error code. |
See also
roomFindResult | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.ROOM_FIND_RESULT
Dispatched when a Rooms search is completed. This event is fired in response to the FindRoomsRequest request to return the search result.
The SFSEvent.ROOM_FIND_RESULT constant defines the value of the type property of the event object for a roomFindResult event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
rooms | Array | A list of Room objects representing the Rooms matching the search criteria. If no Room is found, the list is empty. |
See also
roomGroupSubscribe | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.ROOM_GROUP_SUBSCRIBE
Dispatched when a Group is subscribed by the current user. This event is fired in response to the SubscribeRoomGroupRequest> request if the operation is executed successfully.
The SFSEvent.ROOM_GROUP_SUBSCRIBE constant defines the value of the type property of the event object for a roomGroupSubscribe event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
groupId | String | The name of the Group that was subscribed. |
newRooms | Array | A list of Room objects representing the Rooms belonging to the subscribed Group. |
See also
roomGroupSubscribeError | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.ROOM_GROUP_SUBSCRIBE_ERROR
Dispatched when an error occurs while a Room Group is being subscribed. This event is fired in response to the SubscribeRoomGroupRequest request in case the operation failed.
The SFSEvent.ROOM_GROUP_SUBSCRIBE_ERROR constant defines the value of the type property of the event object for a roomGroupSubscribeError event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
errorMessage | String | A message containing the description of the error. |
errorCode | int | The error code. |
See also
roomGroupUnsubscribe | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.ROOM_GROUP_UNSUBSCRIBE
Dispatched when a Group is unsubscribed by the current user. This event is fired in response to the UnsubscribeRoomGroupRequest> request if the operation is executed successfully.
The SFSEvent.ROOM_GROUP_UNSUBSCRIBE constant defines the value of the type property of the event object for a roomGroupUnsubscribe event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
groupId | String | The name of the Group that was unsubscribed. |
See also
roomGroupUnsubscribeError | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.ROOM_GROUP_UNSUBSCRIBE_ERROR
Dispatched when an error occurs while a Room Group is being unsubscribed. This event is fired in response to the UnsubscribeRoomGroupRequest request in case the operation failed.
The SFSEvent.ROOM_GROUP_UNSUBSCRIBE_ERROR constant defines the value of the type property of the event object for a roomGroupUnsubscribeError event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
errorMessage | String | A message containing the description of the error. |
errorCode | int | The error code. |
See also
roomJoin | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.ROOM_JOIN
Dispatched when a Room is joined by the current user. This event is fired in response to the JoinRoomRequest and QuickJoinGameRequest requests in case the operation is executed successfully.
The SFSEvent.ROOM_JOIN constant defines the value of the type property of the event object for a roomJoin event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
room | Room | An object representing the Room that was joined. |
See also
roomJoinError | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.ROOM_JOIN_ERROR
Dispatched when an error occurs while the current user is trying to join a Room. This event is fired in response to the JoinRoomRequest request in case the operation failed.
The SFSEvent.ROOM_JOIN_ERROR constant defines the value of the type property of the event object for a roomJoinError event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
errorMessage | String | A message containing the description of the error. |
errorCode | int | The error code. |
See also
roomNameChange | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.ROOM_NAME_CHANGE
Dispatched when the name of a Room is changed. This event is fired in response to the ChangeRoomNameRequest request if the operation is executed successfully.
The SFSEvent.ROOM_NAME_CHANGE constant defines the value of the type property of the event object for a roomNameChange event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
room | Room | An object representing the Room which was renamed. |
oldName | String | The previous name of the Room. |
See also
roomNameChangeError | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.ROOM_NAME_CHANGE_ERROR
Dispatched when an error occurs while attempting to change the name of a Room. This event is fired in response to the ChangeRoomNameRequest request in case the operation failed.
The SFSEvent.ROOM_NAME_CHANGE_ERROR constant defines the value of the type property of the event object for a roomNameChangeError event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
errorMessage | String | A message containing the description of the error. |
errorCode | int | The error code. |
See also
roomPasswordStateChange | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.ROOM_PASSWORD_STATE_CHANGE
Dispatched when the password of a Room is set, changed or removed. This event is fired in response to the ChangeRoomPasswordStateRequest request if the operation is executed successfully.
The SFSEvent.ROOM_PASSWORD_STATE_CHANGE constant defines the value of the type property of the event object for a roomPasswordStateChange event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
room | Room | An object representing the Room whose password was changed. |
See also
roomPasswordStateChangeError | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.ROOM_PASSWORD_STATE_CHANGE_ERROR
Dispatched when an error occurs while attempting to set, change or remove the password of a Room. This event is fired in response to the ChangeRoomPasswordStateRequest request in case the operation failed.
The SFSEvent.ROOM_PASSWORD_STATE_CHANGE_ERROR constant defines the value of the type property of the event object for a roomPasswordStateChangeError event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
errorMessage | String | A message containing the description of the error. |
errorCode | int | The error code. |
See also
roomRemove | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.ROOM_REMOVE
Dispatched when a Room belonging to one of the Groups subscribed by the client is removed from the Zone.
The SFSEvent.ROOM_REMOVE constant defines the value of the type property of the event object for a roomRemove event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
room | Room | An object representing the Room that was removed. |
See also
roomVariablesUpdate | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.ROOM_VARIABLES_UPDATE
Dispatched when a Room Variable is updated. This event is caused by the SetRoomVariablesRequest request. The request could have been sent by a user in the same Room of the current user or, in case of a global Room Variable, by a user in a Room belonging to one of the Groups subscribed by the current client.
The SFSEvent.ROOM_VARIABLES_UPDATE constant defines the value of the type property of the event object for a roomVariablesUpdate event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
room | Room | An object representing the Room where the Room Variable update occurred. |
changedVars | Array | The list of names of the Room Variables that were changed (or created for the first time). |
See also
socketError | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.SOCKET_ERROR
Dispatched when a low level socket error is detected, for example bad/inconsistent data.
The SFSEvent.SOCKET_ERROR constant defines the value of the type property of the event object for a socketError event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
errorMessage | String | The description of the error. |
spectatorToPlayer | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.SPECTATOR_TO_PLAYER
Dispatched when a spectator is turned to a player inside a Game Room. This event is fired in response to the SpectatorToPlayerRequest> request if the operation is executed successfully.
The SFSEvent.SPECTATOR_TO_PLAYER constant defines the value of the type property of the event object for a spectatorToPlayer event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
room | Room | An object representing the Room in which the spectator is turned to player. |
user | User | An object representing the spectator who was turned to player. |
playerId | int | The player id of the user. |
See also
spectatorToPlayerError | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.SPECTATOR_TO_PLAYER_ERROR
Dispatched when an error occurs while the current user is being turned from spectator to player in a Game Room. This event is fired in response to the SpectatorToPlayerRequest request in case the operation failed.
The SFSEvent.SPECTATOR_TO_PLAYER_ERROR constant defines the value of the type property of the event object for a spectatorToPlayerError event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
errorMessage | String | A message containing the description of the error. |
errorCode | int | The error code. |
See also
udpInit | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.UDP_INIT
Dispatched when the result of the UDP handshake is notified. This event is fired in response to a call to the initUDP() method.
The SFSEvent.UDP_INIT constant defines the value of the type property of the event object for a udpInit event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
success | Boolean | true if UDP connection initialization is successful, false otherwise. |
See also
userCountChange | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.USER_COUNT_CHANGE
Dispatched when the number of users/players or spectators inside a Room changes. This event is caused by a JoinRoomRequest request or a LeaveRoomRequest request. The Room must belong to one of the Groups subscribed by the current client; also this event might be fired or not depending on the Room configuration defined upon its creation (see the RoomSettings.events setting).
The SFSEvent.USER_COUNT_CHANGE constant defines the value of the type property of the event object for a userCountChange event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
room | Room | An object representing the Room in which the users count changed. |
uCount | int | The new users count (players in case of Game Room). |
sCount | int | The new spectators count (Game Room only). |
See also
userEnterRoom | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.USER_ENTER_ROOM
Dispatched when one of the Rooms joined by the current user is entered by another user. This event is caused by a JoinRoomRequest request; it might be fired or not depending on the Room configuration defined upon its creation (see the RoomSettings.events setting).
NOTE: if the Room is of type MMORoom, this event is never fired and it is substituted by the SFSEvent.PROXIMITY_LIST_UPDATE event.
The SFSEvent.USER_ENTER_ROOM constant defines the value of the type property of the event object for a userEnterRoom event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
user | User | An object representing the user who joined the Room. |
room | Room | An object representing the Room that was joined by a user. |
See also
userExitRoom | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.USER_EXIT_ROOM
Dispatched when one of the Rooms joined by the current user is left by another user, or by the current user himself. This event is caused by a LeaveRoomRequest request; it might be fired or not depending on the Room configuration defined upon its creation (see the RoomSettings.events setting).
NOTE: if the Room is of type MMORoom, this event is fired when the current user leaves the Room only. For the other users leaving the Room it is substituted by the SFSEvent.PROXIMITY_LIST_UPDATE event.
The SFSEvent.USER_EXIT_ROOM constant defines the value of the type property of the event object for a userExitRoom event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
user | User | An object representing the user who left the Room. |
room | Room | An object representing the Room that was left by a user. |
See also
userFindResult | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.USER_FIND_RESULT
Dispatched when a users search is completed. This event is fired in response to the FindUsersRequest request to return the search result.
The SFSEvent.USER_FIND_RESULT constant defines the value of the type property of the event object for a userFindResult event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
users | Array | A list of User objects representing the users matching the search criteria. If no user is found, the list is empty. |
See also
userVariablesUpdate | Event |
com.smartfoxserver.v2.core.SFSEvent
com.smartfoxserver.v2.core.SFSEvent.USER_VARIABLES_UPDATE
Dispatched when a User Variable is updated. This event is caused by the SetUserVariablesRequest request sent by a user in one of the Rooms joined by the current user.
The SFSEvent.USER_VARIABLES_UPDATE constant defines the value of the type property of the event object for a userVariablesUpdate event.The properties of the params object contained in the event object have the following values:
Property | Type | Description |
---|---|---|
user | User | An object representing the user who updated his own User Variables. |
changedVars | Array | The list of names of the User Variables that were changed (or created for the first time). |
See also