SmartFoxServer Silverlight client API
SmartFoxClient is the main class in the SmartFoxServer API.
This class is responsible for connecting to the server and handling all related events.
SmartFoxClient is the main class in the SmartFoxServer API.
This class is responsible for connecting to the server and handling all related events.

C# | Visual Basic | Visual C++ |
public class SmartFoxClient : IDisposable
Public Class SmartFoxClient _ Implements IDisposable
public ref class SmartFoxClient : IDisposable

All Members | Constructors | Methods | Fields | ||
Icon | Member | Description |
---|---|---|
![]() | SmartFoxClient()()() | Initializes a new instance of the SmartFoxClient class |
![]() | SmartFoxClient(Boolean) | The SmartFoxClient contructor. |
![]() | activeRoomId |
The property stores the id of the last room joined by the current user. In most multiuser applications users can join one room at a time: in this case this property represents the id of the current room. If multi-room join is allowed, the application should track the various id(s) in an array (for example) and this property should be ignored. |
![]() | AddBuddy(String) |
Add a user to the buddy list. Since SmartFoxServer Pro 1.6.0, the buddy list feature can be configured to use a basic or advanced security mode (see the SmartFoxServer server-side configuration file). Check the following usage notes for details on the behavior of the AddBuddy method in the two cases. |
![]() | amIModerator |
A boolean flag indicating if the user is recognized as Moderator.
|
![]() | AutoJoin()()() |
Automatically join the the default room (if existing) for the current zone. A default room can be specified in the SmartFoxServer server-side configuration by adding the autoJoin = "true" attribute to one of the <Room>> tags in a zone. When a room is marked as autoJoin it becomes the default room where all clients are joined when this method is called. |
![]() | blueBoxIpAddress |
The BlueBox IP address.
|
![]() | blueBoxPort |
The BlueBox connection port.
|
![]() | buddyList |
A list containing the objects representing each buddy of the user's buddy list. The buddy list can be iterated with a foreach loop, or a specific object can be retrieved by means of the GetBuddyById(Int32) and GetBuddyByName(String) methods. |
![]() | changingRoom |
A boolean flag indicating if the process of joining a new room is in progress.
|
![]() | ClearBuddyList()()() |
Remove all users from the buddy list. Deprecated In order to avoid conflits with the buddy list advanced security mode implemented since SmartFoxServer Pro 1.6.0, buddies should be removed one by one, by iterating through the buddy list. |
![]() | Connect(String) | |
![]() | Connect(String, Int32) |
Establish a connection to SmartFoxServer. The client usually gets connected to SmartFoxServer through a socket connection. In SmartFoxServer Pro, if a socket connection is not available and the smartConnect property is set to true, an http connection to the BlueBox module is attempted. When a successful connection is established, the GetConnectionMode()()() can be used to check the current connection mode. |
![]() ![]() | CONNECTION_MODE_DISCONNECTED |
Connection mode: "disconnected". The client is currently disconnected from SmartFoxServer. |
![]() ![]() | CONNECTION_MODE_HTTP |
Connection mode: "http". The client is currently connected to SmartFoxServer via http. |
![]() ![]() | CONNECTION_MODE_SOCKET |
Connection mode: "socket". The client is currently connected to SmartFoxServer via socket. |
![]() | CreateRoom(NewRoomDescriptor) | |
![]() | CreateRoom(NewRoomDescriptor, Int32) |
Dynamically create a new room in the current zone.
|
![]() | debug |
Toggle the client-side debugging informations. When turned on, the developer is able to inspect all server messages that are sent and received by the client in the Flash authoring environment. This allows a better debugging of the interaction with the server during application developement. |
![]() | defaultZone |
The default login zone.
|
![]() | Disconnect()()() |
Close the current connection to SmartFoxServer.
|
![]() | Dispose()()() | |
![]() | Dispose(Boolean) | |
![]() | Equals(Object) | (Inherited from Object.) |
![]() | Finalize()()() | (Overrides Object.Finalize()()().) |
![]() | GetActiveRoom()()() |
Get the currently active {@link Room} object. SmartFoxServer allows users to join two or more rooms at the same time (multi-room join). If this feature is used, then this method is useless and the application should track the various room id(s) manually, for example by keeping them in an array. |
![]() | GetAllRooms()()() |
Get the list of rooms in the current zone. Unlike the GetRoomList()()() method, this method returns the list of Room objects already stored on the client, so no request is sent to the server. |
![]() | GetBuddyById(Int32) |
Get a buddy from the buddy list, using the user id as key. Refer to the buddyList property for a description of the buddy object's properties. |
![]() | GetBuddyByName(String) |
Get a buddy from the buddy list, using the buddy's username as key. Refer to the buddyList property for a description of the buddy object's properties. |
![]() | GetBuddyRoom(Buddy) |
Request the room id(s) of the room(s) where a buddy is currently located into.
|
![]() | GetConnectionMode()()() |
Get the current connection mode.
|
![]() | GetHashCode()()() |
Serves as a hash function for a particular type.
(Inherited from Object.) |
![]() | GetHttpPollSpeed()()() |
The minimum interval between two polling requests when connecting to SmartFoxServer via BlueBox module. The default value is 750 milliseconds. Accepted values are between 0 and 10000 milliseconds (10 seconds). |
![]() | GetQueuePollSpeed()()() |
The minimum interval between two queue polling requests. The default value is 100 milliseconds. Accepted values are between 0 and 10000 milliseconds (10 seconds). |
![]() | GetRandomKey()()() |
Retrieve a random string key from the server. This key is also referred in the SmartFoxServer documentation as the "secret key". It's a unique key, valid for the current session only. It can be used to create a secure login system. |
![]() | GetRawProtocolSeparator()()() |
Get/set the character used as separator for the string (raw) protocol. The default value is % (percentage character). |
![]() | GetRoom(Int32) |
Get a Room object, using its id as key.
|
![]() | GetRoomByName(String) |
Get a Room object, using its name as key.
|
![]() | GetRoomList()()() |
Retrieve the updated list of rooms in the current zone. Unlike the GetAllRooms()()() method, this method sends a request to the server, which then sends back the complete list of rooms with all their properties and server-side variables (Room Variables). If the default login mechanism provided by SmartFoxServer is used, then the updated list of rooms is received right after a successful login, without the need to call this method. Instead, if a custom login handler is implemented, the room list must be manually requested to the server using this method. |
![]() | GetType()()() |
Gets the Type of the current instance.
(Inherited from Object.) |
![]() | GetUploadPath()()() |
Get the default upload path of the embedded webserver.
|
![]() | GetVersion()()() |
Get the SmartFoxServer Flash API version.
|
![]() | httpPort |
The TCP port used by the embedded webserver. The default port is 8080; if the webserver is listening on a different port number, this property should be set to that value. |
![]() | ipAddress |
The SmartFoxServer IP address.
|
![]() | IsConnected()()() |
A boolean flag indicating if the current user is connected to the server.
|
![]() | JoinRoom(Object) | |
![]() | JoinRoom(Object, String) | |
![]() | JoinRoom(Object, String, Boolean) | |
![]() | JoinRoom(Object, String, Boolean, Boolean) | |
![]() | JoinRoom(Object, String, Boolean, Boolean, Int32) |
Join a room.
|
![]() | LeaveRoom(Int32) |
Disconnect the user from the given room. This method should be used only when users are allowed to be present in more than one room at the same time (multi-room join feature). |
![]() | LoadBuddyList()()() |
Load the buddy list for the current user.
|
![]() | LoadConfig()()() | |
![]() | LoadConfig(String) | |
![]() | LoadConfig(String, Boolean) |
Load a client configuration file. The SmartFoxClient instance can be configured through an external xml configuration file loaded at run-time. By default, the LoadConfig method loads a file named "config.xml", placed in the same folder of the application file. If the autoConnect parameter is set to true, on loading completion the Connect(String, Int32) method is automatically called by the API, otherwise the SFSEvent..::.OnConfigLoadSuccessDelegate event is dispatched. In case of loading error, the SFSEvent..::.OnConfigLoadFailureDelegate event id fired. |
![]() | Login(String, String, String) |
Perform the default login procedure. The standard SmartFoxServer login procedure accepts guest users. If a user logs in with an empty username, the server automatically creates a name for the client using the format guest_n, where n is a progressive number. Also, the provided username and password are checked against the moderators list (see the SmartFoxServer server-side configuration) and if a user matches it, he is set as a Moderator. |
![]() | Logout()()() |
Log the user out of the current zone. After a successful logout the user is still connected to the server, but he/she has to login again into a zone, in order to be able to interact with the server. |
![]() | MemberwiseClone()()() |
Creates a shallow copy of the current Object.
(Inherited from Object.) |
![]() ![]() | MODMSG_TO_ROOM |
Moderator message type: "to room". The Moderator message is sent to all the users in a room. |
![]() ![]() | MODMSG_TO_USER |
Moderator message type: "to user". The Moderator message is sent to a single user. |
![]() ![]() | MODMSG_TO_ZONE |
Moderator message type: "to zone". The Moderator message is sent to all the users in a zone. |
![]() | myBuddyVars |
The current user's Buddy Variables. This is a dictionary containing the current user's properties when he/she is present in the buddy lists of other users. See the SetBuddyVariables(Dictionary<(Of <(String, Object>)>)) method for more details. |
![]() | myUserId |
The current user's SmartFoxServer id. The id is assigned to a user on the server-side as soon as the client connects to SmartFoxServer successfully. |
![]() | myUserName |
The current user's SmartFoxServer username.
|
![]() | playerId |
The current user's id as a player in a game room. The playerId is available only after the user successfully joined a game room. This id is 1-based (player 1, player 2, etc.), but if the user is a spectator or the room is not a game room, its value is -1. When a user joins a game room, a player id (or "slot") is assigned to him/her, based on the slots available in the room at the moment in which the user entered it; for example:
|
![]() | port |
The SmartFoxServer connection port. The default port is 9339. |
![]() | RemoveBuddy(String) |
Remove a buddy from the buddy list. Since SmartFoxServer Pro 1.6.0, the buddy list feature can be configured to use a basic or advanced security mode (see the SmartFoxServer server-side configuration file). Check the following usage notes for details on the behavior of the removeBuddy method in the two cases. |
![]() | RoundTripBench()()() |
Send a roundtrip request to the server to test the connection' speed. The roundtrip request sends a small packet to the server which immediately responds with another small packet, and causing the {@link SFSEvent#onRoundTripResponse} event to be fired. The time taken by the packet to travel forth and back is called "roundtrip time" and can be used to calculate the average network lag of the client. A good way to measure the network lag is to send continuos requests (every 3 or 5 seconds) and then calculate the average roundtrip time on a fixed number of responses (i.e. the last 10 measurements). |
![]() | SendBuddyPermissionResponse(Boolean, String) |
Grant current user permission to be added to a buddy list. If the SmartFoxServer Pro 1.6.0 advanced security mode is used (see the SmartFoxServer server-side configuration), when a user wants to add a buddy to his/her buddy list, a permission request is sent to the buddy. Once the SFSEvent..::.OnBuddyPermissionRequestDelegate event is received, this method must be used by the buddy to grant or refuse permission. When the permission is granted, the requester's buddy list is updated. |
![]() | SendModeratorMessage(String, String) | |
![]() | SendModeratorMessage(String, String, Int32) |
Send a Moderator message to the current zone, the current room or a specific user in the current room. In order to send these kind of messages, the user must have Moderator's privileges, which are set by SmartFoxServer when the user logs in (see the Login(String, String, String) method). |
![]() | SendObject(SFSObject) | |
![]() | SendObject(SFSObject, Int32) |
Send an SFSObject to the other users in the current room. This method can be used to send complex/nested data structures to clients, like a game move or a game status change. Supported data types are: Strings, Booleans, Numbers, Arrays, Objects. |
![]() | SendObjectToGroup(SFSObject, List<(Of <(Int32>)>)) | |
![]() | SendObjectToGroup(SFSObject, List<(Of <(Int32>)>), Int32) |
Send an SFSObject to a group of users in the room.
See SendObject(SFSObject, Int32) for more info.
|
![]() | SendPrivateMessage(String, Int32) | |
![]() | SendPrivateMessage(String, Int32, Int32) |
Send a private message to a user. The message is broadcasted to the recipient and the sender. |
![]() | SendPublicMessage(String) | |
![]() | SendPublicMessage(String, Int32) |
Send a public message. The message is broadcasted to all users in the current room, including the sender. |
![]() | SendXtMessage(String, String, ICollection<(Of <(Object>)>)) | |
![]() | SendXtMessage(String, String, ICollection<(Of <(Object>)>), String) | |
![]() | SendXtMessage(String, String, ICollection<(Of <(Object>)>), String, Int32) |
Send a request to a server side extension. The request can be serialized using three different protocols: XML, JSON and string-based (aka "raw protocol"). XML and JSON can both serialize complex objects with any level of nested properties, while the string protocol allows to send linear data delimited by a separator (see the GetRawProtocolSeparator()()() property). |
![]() | SetBuddyBlockStatus(String, Boolean) |
Block or unblock a user in the buddy list. When a buddy is blocked, SmartFoxServer does not deliver private messages from/to that user. |
![]() | SetBuddyVariables(Dictionary<(Of <(String, Object>)>)) |
Set the current user's Buddy Variables. This method allows to set a number of properties of the current user as buddy of other users; in other words these variables will be received by the other users who have the current user as a buddy. Buddy Variables are the best way to share user's informations with all the other users having him/her in their buddy list.: for example the nickname, the current audio track the user is listening to, etc. The most typical usage is to set a variable containing the current user status, like "available", "occupied", "away", "invisible", etc.). |
![]() | SetHttpPollSpeed(Int32) |
The minimum interval between two polling requests when connecting to SmartFoxServer via BlueBox module. The default value is 750 milliseconds. Accepted values are between 0 and 10000 milliseconds (10 seconds). |
![]() | SetIsConnected(Boolean) | |
![]() | SetQueuePollSpeed(Int32) |
The time between polling for new events.
|
![]() | SetRawProtocolSeparator(String) | |
![]() | SetRoomVariables(List<(Of <(RoomVariable>)>)) | |
![]() | SetRoomVariables(List<(Of <(RoomVariable>)>), Int32) | |
![]() | SetRoomVariables(List<(Of <(RoomVariable>)>), Int32, Boolean) |
Set one or more Room Variables. Room Variables are a useful feature to share data across the clients, keeping it in a centralized place on the server. When a user sets/updates/deletes one or more Room Variables, all the other users in the same room are notified. Allowed data types for Room Variables are Numbers, Strings and Booleans; in order save bandwidth, Arrays and Objects are not supported. Nevertheless, an array of values can be simulated, for example, by using an index in front of the name of each variable (check one of the following examples). If a Room Variable is set to null, it is deleted from the server. |
![]() | SetUserVariables(Dictionary<(Of <(String, Object>)>)) | |
![]() | SetUserVariables(Dictionary<(Of <(String, Object>)>), Int32) |
Set on or more User Variables. User Variables are a useful tool to store user data that has to be shared with other users. When a user sets/updates/deletes one or more User Variables, all the other users in the same room are notified. Allowed data types for User Variables are Numbers, Strings and Booleans; Arrays and Objects are not supported in order save bandwidth. If a User Variable is set to null, it is deleted from the server. Also, User Variables are destroyed when their owner logs out or gets disconnected. |
![]() | smartConnect |
A boolean flag indicating if the BlueBox http connection should be used in case a socket connection is not available. The default value is true. |
![]() | SwitchPlayer()()() | |
![]() | SwitchPlayer(Int32) |
Turn a player inside a game room into a spectator. All players have their player id property set to a value > 0; when a spectator becomes a player, his playerId is set to -1. If the user joined more than one room, the id of the room where the switch should occurr must be passed to this method. The switch operation is successful only if at least one spectator slot is available in the room. |
![]() | SwitchSpectator()()() | |
![]() | SwitchSpectator(Int32) |
Turn a spectator inside a game room into a player. All spectators have their player id property set to -1; when a spectator becomes a player, his player id gets a number > 0, representing the player number. The player id values are assigned by the server, based on the order in which the players joined the room. If the user joined more than one room, the id of the room where the switch should occur must be passed to this method. The switch operation is successful only if at least one player slot is available in the room. |
![]() | ToString()()() | (Inherited from Object.) |
![]() | UploadFile(String) | |
![]() | UploadFile(String, Int32) | |
![]() | UploadFile(String, Int32, String) | |
![]() | UploadFile(String, Int32, String, Int32) |
Upload a file to the embedded webserver.
|
![]() ![]() | XTMSG_TYPE_JSON |
Server-side extension request/response protocol: JSON.
|
![]() ![]() | XTMSG_TYPE_STR |
Server-side extension request/response protocol: string (aka "raw protocol").
|
![]() ![]() | XTMSG_TYPE_XML |
Server-side extension request/response protocol: XML.
|

NOTE:
in the provided examples, smartFox always indicates a SmartFoxClient instance.
Version:
1.0.0
Author:
Thomas Hentschel Lund
http://www.fullcontrol.dk
sfs-api@fullcontrol.dk
http://www.smartfoxserver.com
http://www.gotoandplay.it

Object | |
![]() | SmartFoxClient |