SmartFox2X
SmartFox is the main class of the SmartFoxServer 2X API.
This class is responsible for connecting the client to a SmartFoxServer instance and for dispatching all asynchronous events. Developers always interact with SmartFoxServer through this class.
NOTE: in the provided examples, sfs always indicates a SmartFox instance.
Author: The gotoAndPlay() Team
http://www.smartfoxserver.com
Creates a new SmartFox instance.
The following example instantiates the SmartFox class without enabling the debug messages:
SmartFox sfs = new SmartFox();
Creates a new SmartFox instance.
If true, the SmartFoxServer API debug messages are logged.
The following example instantiates the SmartFox class enabling the debug messages:
SmartFox sfs = new SmartFox(true);
Creates a new SmartFox instance enabling websocket communication instead of the default socket communication.
IMPORTANT: this constructor should be used in Unity only and when building for the web only (Unity WEBGL).
In fact it is preferable to use the default socket communication, as websocket connection doesn't support BlueBox and HRC systems, the protocol is not binary and not compressed.
This constructor is not available in .Net and Windows Universal DLLs (websocket communication not supported, because redundant).
Starting from API v1.7.3, websocket communication uses the default SFS2X binary protocol (see UseWebSocket class). Legacy text protocol is still available for backward compatibility with SmartFoxserver 2X versions prior to 2.13.
If set to UseWebSocket.WS_BIN, non-secure websocket communication (WS) is used; if set to UseWebSocket.WSS_BIN, secure websocket communication (WSS) is used.
The following example instantiates the SmartFox class enabling websocket communication:
SmartFox sfs = new SmartFox(UseWebSocket.WS_BIN);
Creates a new SmartFox instance enabling websocket communication instead of the default socket communication.
IMPORTANT: this constructor should be used in Unity only and when building for the web only (Unity WEBGL).
In fact it is preferable to use the default socket communication, as websocket connection doesn't support BlueBox and HRC systems, the protocol is not binary and not compressed.
This constructor is not available in .Net and Windows Universal DLLs (websocket communication not supported, because redundant).
Starting from API v1.7.3, websocket communication uses the default SFS2X binary protocol (see UseWebSocket class). Legacy text protocol is still available for backward compatibility with SmartFoxserver 2X versions prior to 2.13.
If set to UseWebSocket.WS_BIN, non-secure websocket communication (WS) is used; if set to UseWebSocket.WSS_BIN, secure websocket communication (WSS) is used.
If true, the SmartFoxServer API debug messages are logged.
The following example instantiates the SmartFox class enabling secure websocket communication and debug messages:
SmartFox sfs = new SmartFox(UseWebSocket.WSS_BIN, true);
Allows to set custom client details used to gather statistics about the client platform in the SFS2X Analytics Module.
This method must be called before the connection is started.
The length of the two strings combined must be < 512 characters.
By default the generic "Unity" and "Windows Universal" labels (depending on the used DLL) are set as platform, without specifying the version.
The id of the runtime platform: for example "Unity WebPlayer" or "iOS".
An optional version of the runtime platform: for example "2.0.0".
Enables the automatic realtime monitoring of the lag between the client and the server (round robin).
When turned on, the event type is dispatched continuously, providing the average of the last ten measured lag values.
The lag monitoring can be enabled after the login has been performed successfully only and it is automatically halted when the user logs out of a Zone or gets disconnected.
The lag monitoring status: true to start the monitoring, false to stop it.
(default: 4) An optional amount of seconds to wait between each query (recommended 3-4s).
(default: 10) The amount of values stored temporarily and used to calculate the average lag.
See .
See .
Indicates whether the client is connected to the server or not.
The following example checks the connection status:
Console.WriteLine("Am I connected? " + sfs.IsConnected); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Am I connected? " + sfs.IsConnected); // Windows Universal
Returns the current version of the SmartFoxServer 2X C# API.
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.
Returns the client configuration details.
Indicates whether the client should attempt a tunnelled http connection through the BlueBox in case a socket connection can't be established.
This property must be set before the 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 property.
BlueBox connection is not available if websocket connection is used.
Returns the current connection mode after a connection has been successfully established.
Possible values are:
- HTTP: a tunnelled http connection (through the BlueBox) was established between the client and the server
- Socket: a regular socket connection was established between the client and the server
- WebSocket: a websocket connection was established between the client and the server (not available in Windows / Windows Phone)
- WebSocketSecure: a secure websocket connection was established between the client and the server (not available in Windows / Windows Phone)
The following example shows the current connection mode:
Console.WriteLine("Connection mode: " + sfs.ConnectionMode); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Connection mode: " + sfs.ConnectionMode); // native windows / windows phone
Returns the current compression threshold.
This value represents the maximum message size (in bytes) before the protocol compression is activated and it is determined by the server configuration.
Compression threshold doesn't apply if websocket connection is used.
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-side configuration.
Retrieves a Room object from its id.
The same object is returned by the IRoomManager.getRoomById() method, accessible through the getter;
this was replicated on the SmartFox class for handy access due to its usually frequent usage.
The id of the Room.
An object representing the requested Room; null if no object with the passed id exists in the Rooms list.
The following example retrieves a object and writes its name:
int roomId = 3;
Room room = sfs.GetRoomById(roomId);
Console.WriteLine("The name of Room " + roomId + " is " + room.Name); // .Net / Unity
System.Diagnostics.Debug.WriteLine("The name of Room " + roomId + " is " + room.Name); // Windows Universal
Retrieves a Room object from its name.
The same object is returned by the IRoomManager.getRoomById() method, accessible through the getter;
this was replicated on the SmartFox class for handy access due to its usually frequent usage.
The name of the Room.
An object representing the requested Room; null if no object with the passed name exists in the Rooms list.
The following example retrieves a object and writes its id:
string roomName = "The Lobby";
Room room = sfs.GetRoomByName(roomName);
Console.WriteLine("The id of Room '" + roomName + "' is " + room.Id); // .Net / Unity
System.Diagnostics.Debug.WriteLine("The id of Room '" + roomName + "' is " + room.Id); // Windows Universal
Retrieves the list of Rooms which are part of the specified Room Group.
The same list is returned by the IRoomManager.getRoomById() method, accessible through the getter;
this was replicated on the SmartFox class for handy access due to its usually frequent usage.
The name of the Group.
The list of objects belonging to the passed Group.
Simulates an abrupt disconnection from the server.
This method should be used for testing and simulations only, otherwise use the method.
This method is not supported in case of websocket connection.
Establishes a connection between the client and a SmartFoxServer 2X instance.
If no argument is passed, the client will use the settings loaded via 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 as a fail-safe system.
When a successful connection is established, the ConnectionMode property can be used to check the current connection mode.
Tunnelled http connection is not available in case of websocket connection.
When using a websocket connection to an IPv6 address, always wrap the host value in square brackets.
The address of the server to connect to.
The TCP port to connect to.
If an invalid host/address or port is passed, and it can't be found in the loaded settings.
The following example connects to a local SmartFoxServer 2X instance:
void SomeMethod() {
SmartFox sfs = new SmartFox();
sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
sfs.Connect("127.0.0.1", 9933);
}
void OnConnection(BaseEvent evt) {
if ((bool)evt.Params["success"])
{
Console.WriteLine("Connection was established"); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Connection was established"); // Windows Universal
}
else
{
Console.WriteLine("Connection failed"); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Connection failed"); // Windows Universal
}
}
See .
See .
Establishes a connection between the client and a SmartFoxServer 2X instance using a configuration object.
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 as a fail-safe system.
When a successful connection is established, the ConnectionMode property can be used to check the current connection mode.
Tunnelled http connection is not available in case of websocket connection.
The client configuration object.
If an invalid host/address or port is passed, and it can't be found in the loaded settings.
The following example connects to a local SmartFoxServer 2X instance:
ConfigData cfg = new ConfigData();
cfg.Host = "127.0.0.1";
cfg.Port = 9933;
cfg.Zone = "BasicExamples";
sfs.Connect(cfg);
Closes the connection between the client and the SmartFoxServer 2X instance.
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.
Returns the IP address or domain name of the SmartFoxServer 2X instance to which the client is connected.
Returns the TCP port of the SmartFoxServer 2X instance to which the client is connected.
Returns the Zone currently in use, if the user is already logged in.
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 this property manually can disrupt the API functioning.
Returns a reference to the internal Logger instance used by SmartFoxServer 2X.
Returns the object representing the last Room joined by the client, if any.
This property is null if no Room was joined.
NOTE: setting this property manually can disrupt the API functioning.
Use the request to join a new Room instead.
Returns a list of Room objects representing the Rooms currently joined by the client.
The same list is returned by the IRoomManager.getRoomById() method, accessible through the getter;
this was replicated on the SmartFox class for handy access due to its usually frequent usage.
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.
At login time, the client automatically subscribes all the Room Groups specified in the Zone's Default Room Groups setting.
The same list is returned by the IRoomManager.getRoomById() method, accessible through the getter;
this was replicated on the SmartFox class for handy access due to its usually frequent usage.
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 objects.
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 objects.
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 and objects and access to user properties in the Buddy List system.
Indicates whether the UPD protocol is available or not in the current runtime.
UPD protocol is always available and this property always returns true, unless websocket connection is used.
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.
Indicates whether the UDP handshake has been performed successfully or not.
Initializes the UDP protocol by performing an handshake with the server.
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.
If udpHost or udpPort arguments are not passed, the client will use the settings loaded via method.
UDP protocol is not available in case of websocket connection.
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's no fixed size for the MTU, each operating system uses a slighlty different size.
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 larger data to send we suggest to organize it in smaller chunks so that they don't exceed the suggested MTU size.
More details about the MTU can be found here: .
The IP address of the server to connect to.
he UDP port to connect to.
The following example initializes the UDP communication, sends a request to an Extension and handles the related events:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.UPD_INIT, OnUDPInit);
sfs.InitUDP();
}
void OnUDPInit(BaseEvent evt) {
if ((bool)evt.Params["success"]) {
// Execute an extension call via UDP
sfs.Send( new ExtensionRequest("udpTest", new SFSObject(), null, true) ):
} else {
Console.WriteLine("UDP init failed!"); // .Net / Unity
System.Diagnostics.Debug.WriteLine("UDP init failed!"); // Windows Universal
}
}
See .
See .
Initializes the connection cryptography to protect all client-server communications with standard TLS protocol.
This method must be called right after a successful connection, before the login is performed.
Once the encryption initialization 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.
IMPORTANT UNITY REMARKS
In Unity this method must be executed as a coroutine, hence using MonoBehaviour.StartCoroutine method.
For this reason, in case the Unity project is built for Windows Store (SDK 8.1, Phone 8.1, Universal 8.1), a conditional statement is required as in the example below.
This method is not available when building for WebGL: use WSS connection instead.
When building for the Web Player, do not use Security.PrefetchSocketPolicy in your code. In fact this method accepts an IP address only, while you should connect to the domain name instead, since the SSL certificate is (typically) bound to that.
Let the Web Player auto-fetch the cross-domain policy from the default TCP port 843. In order to do this, add a listener for such port in the SFS2X AdminTool's Server Configurator module.
The following example initializes the encrypted communication:
void SomeMethod() {
SmartFox sfs = new SmartFox();
sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
sfs.AddEventListener(SFSEvent.CRYPTO_INIT, OnEncryptionInitialized);
sfs.Connect("mysecuredomain.com", 9933);
}
void OnConnection(BaseEvent evt) {
if ((bool)evt.Params["success"])
{
Console.WriteLine("Connection was established");
// Initialize encrypted connection
#if UNITY_WINRT && !UNITY_EDITOR
sfs.InitCrypto();
#else
StartCoroutine(sfs.InitCrypto());
#endif
}
else
{
Console.WriteLine("Connection failed");
}
}
void OnEncryptionInitialized(BaseEvent evt) {
if ((bool)evt.Params["success"])
{
// Do login
sfs.Send( new LoginRequest("FozzieTheBear", "", "SimpleChat") );
}
else
{
Console.WriteLine("Encryption initialization failed. Caused by: " + (string)evt.Params["errorMsg"]);
}
}
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.
Sets the API to run with an event queue that needs to be processed by the client.
By default this property is set to true in the Unity DLL. Instead it is set to false in the Windows / Windows Phone Universal and .Net DLLs, for native usage of the SmartFoxServer 2X API.
When using the API in Unity, this must be true, otherwise random crashes can happen.
For this reason, when building an application/game for Windows / Windows Phone using Unity, always remember to set this property to true explicitly!
Sends a request to the server.
All the available request objects can be found under the namespace.
A request object.
The following example sends a login request:
sfs.Send( new LoginRequest("KermitTheFrog", "KermitPass", "TheMuppetZone") );
The following example sends a login request:
sfs.Send( new JoinRoomRequest("Lobby") );
The following example creates an object containing some parameters and sends it to the server-side Extension.
ISFSObject parameters = SFSObject.NewInstance();
parameters.SetInt("x", 10);
parameters.SetInt("y", 37);
sfs.Send( new ExtensionRequest("setPosition", parameters) );
Loads the client configuration file.
The SmartFox instance can be configured through an external xml configuration file loaded at run-time.
By default, this method loads a file named "sfs-config.xml", placed in the same folder of the application file.
If the AutoConnect parameter is set to true, on loading completion the method is automatically called by the API, otherwise the event is dispatched.
In case of loading error, the event id fired.
The external xml configuration file has the following structure; ip, port and zone parameters are mandatory, all other parameters are optional.
<SmartFoxConfig>
<host>127.0.0.1</host>
<port>9933</port>
<udpHost>127.0.0.1</udpHost>
<udpPort>9933</udpPort>
<zone>simpleChat</zone>
<debug>true</debug>
<httpPort>8080</httpPort>
<httpsPort>8443</httpsPort>
<useBlueBox>true</useBlueBox>
<blueBoxPollingRate>750</blueBoxPollingRate>
</SmartFoxConfig>
(default: sfs-config.xml) Filename of the external XML configuration, including its path relative to the folder of the application file.
(default: true) A flag indicating if the connection to SmartFoxServer must be attempted upon configuration loading completion.
The following example shows how to load an external configuration file:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.CONFIG_LOAD_SUCCESS, OnConfigLoadSuccessHandler);
sfs.AddEventListener(SFSEvent.CONFIG_LOAD_FAILURE, OnConfigLoadFailureHandler);
sfs.LoadConfig("testEnvironmentConfig.xml", false);
}
void OnConfigLoadSuccessHandler(BaseEvent evt) {
Console.WriteLine("Config file loaded, now connecting...");
sfs.Connect(sfs.IpAddress, sfs.Port);
}
void OnConfigLoadFailureHandler(BaseEvent evt) {
Console.WriteLine("Failed loading config file: " + evt.Params["message"]);
}
See .
See .
See .
Registers a delegate method for log messages callbacks.
Calling this method is just like calling the Logger.AddEventListener method directly,
but in addition the Logger.EnableEventDispatching property is automatically set to true.
The level of the log events to register a listener for.
The event listener to register.
void SomeMethod() {
sfs.AddLogListener(LogLevel.INFO, OnInfoLogMessage);
sfs.AddLogListener(LogLevel.WARN, OnWarnLogMessage);
}
void OnInfoLogMessage(BaseEvent evt) {
string message = (string)evt.Params["message"];
Console.WriteLine("[SFS2X INFO] " + message); // .Net / Unity
System.Diagnostics.Debug.WriteLine("[SFS2X INFO] " + message); // Windows Universal
}
void OnWarnLogMessage(BaseEvent evt) {
string message = (string)evt.Params["message"];
Console.WriteLine("[SFS2X WARN] " + message); // .Net / Unity
System.Diagnostics.Debug.WriteLine("[SFS2X WARN] " + message); // Windows Universal
}
Removes a delegate method for log messages callbacks.
Calling this method is just like calling the Logger.RemoveEventListener method directly.
The level of the log events to remove the listener for.
The event listener to remove.
Tells the API to process all event queues and execute the delegate callbacks.
This method must be called by the client application to maintain thread safety, in conjunction with the ThreadSafeMode property being set to true.
Typically this method is called in Unity's MonoBehavior.Update method.
void FixedUpdate() {
sfs.ProcessEvents();
}
Adds a delegate to a given API event type that will be used for callbacks.
The name of the to get callbacks on.
The delegate method to register.
void SomeMethod() {
sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
}
public void OnConnection(BaseEvent evt) {
bool success = (bool)evt.Params["success"];
string error = (string)evt.Params["error"];
Debug.Log("On Connection callback got: " + success + " (error : " + error + ")");
}
Removes a delegate registration for a given API event.
The SFSEvent to remove callbacks on.
The delegate method to unregister.
Removes all event listeners.
Please note that log delegates need to be removed separately using the method.
@private
@private
This is the base class of all the events dispatched by the SmartFoxServer 2X C# API.
An Dictionary (Windows Universal) or Hashtable (all other platforms) containing the event's parameters.
This class represents all the events related to the Buddy List system dispatched by the SmartFoxServer 2X C# API.
Dispatched if the Buddy List system is successfully initialized.
This event is fired in response to the 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 object contains the following parameters:
Parameter
Description
-
buddyList
(List<>) A list of objects representing all the buddies in the current user's buddies list.
-
myVariables
(List<>) The list of all objects associated with the current user.
See the example.
Dispatched when a buddy is added successfully to the current user's buddies list.
This event is fired in response to the request in case the operation is executed successfully.
The object contains the following parameters:
Parameter
Description
-
buddy
() The object corresponding to the buddy that was added.
See the example.
Dispatched when a buddy is removed successfully from the current user's buddies list.
This event is fired in response to the request in case the operation is executed successfully.
The object contains the following parameters:
Parameter
Description
-
buddy
() The object corresponding to the buddy that was removed.
See the example.
Dispatched when a buddy is blocked or unblocked successfully by the current user.
This event is fired in response to the request in case the operation is executed successfully.
The object contains the following parameters:
Parameter
Description
-
buddy
() The object corresponding to the buddy that was blocked/unblocked.
See the example.
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 request, the , etc.
The object contains the following parameters:
Parameter
Description
-
errorMessage
(string) The message which describes the error.
-
errorCode
(short) The error code.
See the example.
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 request 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 object contains the following parameters:
Parameter
Description
-
buddy
() The 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
(bool) 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 the example.
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 request 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 object contains the following parameters:
Parameter
Description
-
buddy
() The 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).
-
changedVars
(IList<string>) The list of names of the Buddy Variables that were changed (or created for the first time).
-
isItMe
(bool) true if the Buddy Variables were updated by the current user himself (in this case this event is a sort of update confirmation).
See the example.
Dispatched when a message from a buddy is received by the current user.
This event is fired in response to the request.
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 object contains the following parameters:
Parameter
Description
-
buddy
() The 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
(bool) 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
() An object containing additional custom parameters (e.g. the message color, an emoticon id, etc).
See the example.
This class represents most of the events dispatched by the SmartFoxServer 2X C# API.
Dispatched when the result of the UDP handshake is notified.
This event is fired in response to a call to the SmartFox.InitUDP() method.
The object contains the following parameters:
Parameter
Description
-
success
(bool) true if UDP connection initialization is successful, false otherwise.
See the example.
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 method.
The object contains the following parameters:
Parameter
Description
-
success
(bool) The connection result: true if a connection was established, false otherwise.
See the example.
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 SmartFox.EnableLagMonitor method.
The object contains the following parameters:
Parameter
Description
-
lagValue
(int) The average of the last ten measured lag values, expressed in milliseconds.
Dispatched when a low level socket error is detected, for example bad/inconsistent data.
The object contains the following parameters:
Parameter
Description
-
errorMessage
(string) The description of the error.
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 method or when the connection between the client and the server is interrupted for other reasons.
The object contains the following parameters.
Parameter
Description
-
reason
(string) The reason of the disconnection, among those available in the class.
The following example handles a disconnection event:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.OnConnectionLost, OnConnectionLost);
}
void OnConnectionLost(BaseEvent evt) {
Console.WriteLine("Connection was lost, Reason: " + (string)evt.Params["reason"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Connection was lost, Reason: " + (string)evt.Params["reason"]); // Windows Universal
}
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 losing 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 event is fired,
or the reconnection fails and the user is definitely disconnected and the event is fired.
No parameters are available for this event object.
The following example shows how to handle a reconnection
void SomeMethod() {
sfs.AddEventListener(SFSEvent.CONNECTION_RETRY, OnConnectionRetry);
sfs.AddEventListener(SFSEvent.CONNECTION_RESUME, OnConnectionResume);
sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
}
void OnConnectionRetry(BaseEvent evt) {
// Freeze your GUI and provide some feedback to the Player
...
}
void OnConnectionResume(BaseEvent evt) {
// Unfreeze the GUI and let the player continue with the game
...
}
void OnConnectionLost(BaseEvent evt) {
Console.WriteLine("Ouch, connection was lost! Reason: " + (string)evt.Params["reason"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Ouch, connection was lost! Reason: " + (string)evt.Params["reason"]); // Windows Universal
}
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 losing 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 event is fired.
No parameters are available for this event object.
See the example.
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).
No parameters are available for this event object.
Dispatched when the external client configuration file is loaded successfully.
This event is fired in response to a call to the method, but only if the connectOnSuccess argument of that method is set to false;
otherwise the connection is attempted and the related event type is fired.
No parameters are available for this event object.
See the example.
Dispatched when an error occurs while loading the external SmartFox configuration file.
This event is fired in response to a call to the method, typically when the configuration file is not found or it isn't accessible (no read permissions).
No parameters are available for this event object.
See the example.
Dispatched when the current user performs a successful login in a server Zone.
This event is fired in response to the request.
The object contains the following parameters:
Parameter
Description
-
user
() An object representing the user who performed the login.
-
data
() An object containing custom parameters returned by a custom login system, if any.
See the example.
Dispatched if an error occurs while the user login is being performed.
This event is fired in response to the request in case the operation failed.
The object contains the following parameters:
Parameter
Description
-
errorMessage
(string) A message containing the description of the error.
-
errorCode
(short) The error code.
See the example.
Dispatched when the current user performs logs out of the server Zone.
This event is fired in response to the request.
No parameters are available for this event object.
See the example.
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 and requests in case the operation is executed successfully.
The object contains the following parameters:
Parameter
Description
-
room
() An object representing the Room that was created.
See the example.
Dispatched when a Room belonging to one of the Groups subscribed by the client is removed from the Zone.
The object contains the following parameters:
Parameter
Description
-
room
() An object representing the Room that was removed.
Dispatched if an error occurs while creating a new Room.
This event is fired in response to the and requests in case the operation failed.
The object contains the following parameters:
Parameter
Description
-
errorMessage
(string) A message containing the description of the error.
-
errorCode
(short) The error code.
See the example.
Dispatched when a Room is joined by the current user.
This event is fired in response to the and requests in case the operation is executed successfully.
The object contains the following parameters:
Parameter
Description
-
room
() An object representing the Room that was joined.
See the example.
Dispatched when an error occurs while the current user is trying to join a Room.
This event is fired in response to the request in case the operation failed.
The object contains the following parameters:
Parameter
Description
-
errorMessage
(string) A message containing the description of the error.
-
errorCode
(short) The error code.
See the example.
Dispatched when one of the Rooms joined by the current user is entered by another user.
This event is caused by a 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 event.
The object contains the following parameters:
Parameter
Description
-
user
() An object representing the user who joined the Room.
-
room
() An object representing the Room that was joined by a user.
The following example shows how to handle this event type:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.USER_ENTER_ROOM, OnUserEnterRoom);
}
void OnUserEnterRoom(BaseEvent evt) {
Room room = (Room)evt.Params["room"];
User user = (User)evt.Params["user"];
Console.WriteLine("User: " + user.Name + " has just joined Room: " + room.Name); // .Net / Unity
System.Diagnostics.Debug.WriteLine("User: " + user.Name + " has just joined Room: " + room.Name); // Windows Universal
}
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 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 event.
The object contains the following parameters:
Parameter
Description
-
user
() An object representing the user who left the Room.
-
room
() An object representing the Room that was left by the user.
The following example shows how to handle this event type:
void SomeMethod() {
smartFox.AddEventListener(SFSEvent.USER_EXIT_ROOM, OnUserExitRoom);
}
void OnUserExitRoom(BaseEvent evt) {
Room room = (Room)evt.Params["room"];
User user = (User)evt.Params["user"];
Console.WriteLine("User: " + user.Name + " has just left Room: " + room.Name); // .Net / Unity
System.Diagnostics.Debug.WriteLine("User: " + user.Name + " has just left Room: " + room.Name); // Windows Universal
}
Dispatched when the number of users/players or spectators inside a Room changes.
This event is caused by a request or a 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 object contains the following parameters:
Parameter
Description
-
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 Rooms only).
The following example shows how to handle this event type:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.USER_COUNT_CHANGE, OnUserCountChange);
}
void OnUserCountChange(BaseEvent evt) {
Room room = (Room)evt.Params["room"];
int uCount = (int)evt.Params["uCount"];
int sCount = (int)evt.Params["sCount"];
Console.WriteLine("Room: " + room.Name + " contains " + uCount + " users and " + sCount + " spectators"); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Room: " + room.Name + " contains " + uCount + " users and " + sCount + " spectators"); // Windows Universal
}
Dispatched when a public message is received by the current user.
This event is caused by a request sent by any user in the target Room, including the current user himself.
The object contains the following parameters:
Parameter
Description
-
room
() An object representing the Room at which the message is targeted.
-
sender
() An object representing the user who sent the message.
-
message
(string) The message sent by the user.
-
data
() An object containing custom parameters which might accompany the message.
See the example.
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.
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 object contains the following parameters:
Parameter
Description
-
sender
() An object representing the user who sent the message.
-
message
(string) The message sent by the user.
-
data
() An object containing custom parameters which might accompany the message.
See the example.
Dispatched when the current user receives a message from a moderator user.
This event can be caused by the , or 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 object contains the following parameters:
Parameter
Description
-
sender
() An object representing the moderator user who sent the message.
-
message
(string) The message sent by the moderator.
-
data
() An object containing custom parameters which might accompany the message.
See the example.
Dispatched when the current user receives a message from an administrator user.
This event is caused by the request sent by a user with administration privileges.
The object contains the following parameters:
Parameter
Description
-
sender
() An object representing the administrator user who sent the message.
-
message
(string) The message sent by the administrator.
-
data
() An object containing custom parameters which might accompany the message.
See the example.
Dispatched when an object containing custom data is received by the current user.
This event is caused by an request sent by any user in the target Room.
The object contains the following parameters:
Parameter
Description
-
sender
() An object representing the user who sent the message.
-
message
() The content of the message: an object containing the custom parameters sent by the sender.
See the example.
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 object contains the following parameters:
Parameter
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.
-
sourceRoom
(int) [DEPRECATED - Use room property] The id of the Room which the Extension is attached to (for Room Extensions only).
-
room
() An object representing the Room which the Extension is attached to (for Room Extensions only).
-
params
() An object containing custom data sent by the Extension.
-
packetId
(long) 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 (for UDP communication only).
See the example.
Dispatched when a Room Variable is updated.
This event is caused by the 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 object contains the following parameters:
Parameter
Description
-
room
() An object representing the Room where the Room Variable update occurred.
-
changedVars
(List<string>) the list of variable names that where modified or created
See the example.
Dispatched when a User Variable is updated.
This event is caused by the request sent by a user in one of the Rooms joined by the current user.
The object contains the following parameters:
Parameter
Description
-
user
() An object representing the user who updated his own User Variables.
-
changedVars
(List<string>) The list of names of the User Variables that were changed (or created for the first time).
See the example.
Dispatched when a Group is subscribed by the current user.
This event is fired in response to the request if the operation is executed successfully.
The object contains the following parameters:
Parameter
Description
-
groupId
(string) The name of the Group that was subscribed.
-
newRooms
(List<>) A list of objects representing the Rooms belonging to the subscribed Group.
See the example.
Dispatched when a Group is unsubscribed by the current user.
This event is fired in response to the request if the operation is executed successfully.
The object contains the following parameters:
Parameter
Description
-
groupId
(string) The name of the Group that was unsubscribed.
See the example.
Dispatched when an error occurs while a Room Group is being subscribed.
This event is fired in response to the request in case the operation failed.
The object contains the following parameters:
Parameter
Description
-
errorMessage
(string) A message containing the description of the error.
-
errorCode
(short) The error code.
See the example.
Dispatched when an error occurs while a Room Group is being unsubscribed.
This event is fired in response to the request in case the operation failed.
The object contains the following parameters:
Parameter
Description
-
errorMessage
(string) A message containing the description of the error.
-
errorCode
(short) The error code.
See the example.
Dispatched when a spectator is turned to a player inside a Game Room.
This event is fired in response to the request if the operation is executed successfully.
The object contains the following parameters:
Parameter
Description
-
room
() An object representing the Room in which the spectator is turned to player.
-
user
() An object representing the spectator who was turned to player.
-
playerId
(int) The player id of the user.
See the example.
Dispatched when a player is turned to a spectator inside a Game Room.
This event is fired in response to the request if the operation is executed successfully.
The object contains the following parameters:
Parameter
Description
-
room
() An object representing the Room in which the player is turned to spectator.
-
user
() An object representing the player who was turned to spectator.
See the example.
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 request in case the operation failed.
The object contains the following parameters:
Parameter
Description
-
errorMessage
(string) A message containing the description of the error.
-
errorCode
(short) The error code.
See the example.
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 request in case the operation failed.
The object contains the following parameters:
Parameter
Description
-
errorMessage
(string) A message containing the description of the error.
-
errorCode
(short) The error code.
See the example.
Dispatched when the name of a Room is changed.
This event is fired in response to the request if the operation is executed successfully.
The object contains the following parameters:
Parameter
Description
-
room
() An object representing the Room which was renamed.
-
oldName
(string) The previous name of the Room.
See the example.
Dispatched when an error occurs while attempting to change the name of a Room.
This event is fired in response to the request in case the operation failed.
The object contains the following parameters:
Parameter
Description
-
errorMessage
(string) A message containing the description of the error.
-
errorCode
(short) The error code.
See the example.
Dispatched when the password of a Room is set, changed or removed.
This event is fired in response to the request if the operation is executed successfully.
The object contains the following parameters:
Parameter
Description
-
room
() An object representing the Room whose password was changed.
See the example.
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 request in case the operation failed.
The object contains the following parameters:
Parameter
Description
-
errorMessage
(string) A message containing the description of the error.
-
errorCode
(short) The error code.
See the example.
Dispatched when the capacity of a Room is changed.
This event is fired in response to the request if the operation is executed successfully.
The object contains the following parameters:
Parameter
Description
-
room
() An object representing the Room whose capacity was changed.
See the example.
Dispatched when an error occurs while attempting to change the capacity of a Room.
This event is fired in response to the request in case the operation failed.
The object contains the following parameters:
Parameter
Description
-
errorMessage
(string) A message containing the description of the error.
-
errorCode
(short) The error code.
See the example.
Dispatched when a Rooms search is completed.
This event is fired in response to the request to return the search result.
The object contains the following parameters:
Parameter
Description
-
rooms
(List<>) A list of Room objects representing the Rooms matching the search criteria. If no Room is found, the list is empty.
See the example.
Dispatched when a users search is completed
This event is fired in response to the request to return the search result.
The object contains the following parameters:
Parameter
Description
-
rooms
(List<>) A list of objects representing the users matching the search criteria. If no user is found, the list is empty.
See the example.
Dispatched when the current user receives an invitation from another user.
This event is caused by the request; the user is supposed to reply using the request.
The object contains the following parameters:
Parameter
Description
-
invitation
() An object representing the invitation received by the current user.
See the example.
Dispatched when the current user receives a reply to an invitation he sent previously.
This event is caused by the request sent by the invitee.
The object contains the following parameters:
Parameter
Description
-
invitee
() An object representing the user who replied to the invitation.
-
reply
(int) The answer to the invitation among those available as constants in the class.
-
data
() An object containing custom parameters, for example a message describing the reason of refusal.
See the example.
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 request in case the operation failed.
The object contains the following parameters:
Parameter
Description
-
errorMessage
(string) A message containing the description of the error.
-
errorCode
(short) The error code.
See the example.
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 request is sent at least one time.
NOTE: this event substitutes the default and events available in regular Rooms.
The object contains the following parameters:
Parameter
Description
-
room
(Room) The Room where the event occurred
-
addedUsers
(List<User>) A list of User objects representing the users who entered the current user's Area of Interest.
-
removedUsers
(List<User>) A list of User objects representing the users who left the current user's Area of Interest.
-
addedItems
(List<IMMOItem>) A list of MMOItem objects which entered the current user's Area of Interest.
-
removedItems
(List<IMMOItem>) A list of MMOItem objects which left the current user's Area of Interest.
See the example.
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 object contains the following parameters:
Parameter
Description
-
room
() The MMORoom where the MMOItem whose Variables have been updated is located.
-
mmoItem
() The MMOItem whose variables have been updated.
-
changedVars
(List<string>) The list of names of the MMOItem Variables that were changed (or created for the first time).
The following example shows how to handle the MMOItem Variable update:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.MMOITEM_VARIABLES_UPDATE, OnMMOItemVarsUpdate);
}
void OnMMOItemVarsUpdate(BaseEvent evt) {
var changedVars = (List<String>)evt.Params["changedVars"];
var item = (IMMOItem) evt.Params["mmoItem"];
// Check if the MMOItem was moved
if (changedVars.Contains("x") || changedVars.Contains("y"))
{
// Move the sprite representing the MMOItem
...
}
}
Dispatched in return to the initialization of an encrypted connection.
This event is fired in response to a call to the SmartFox.InitCrypto() method.
The object contains the following parameters:
Parameter
Description
-
success
(bool) true if a unique encryption key was successfully retrieved via HTTPS, false if the transaction failed.
-
errorMessage
(string) If success is false, provides additional details on the occurred error.
See the example.
This method is called whenever the SmartFox.ProcessEvents is called, to run the logic processing the errors and queues in the WebSocketHelper class.
The Buddy interface defines all the methods and properties that an object representing a SmartFoxServer Buddy entity exposes.
In the SmartFoxServer 2X client API this interface is implemented by the class. Read the class description for additional informations.
Indicates the id of this buddy.
This is equal to the id assigned by SmartFoxServer to the corresponding user.
Indicates the name of this buddy.
This is equal to the name of the corresponding user.
Indicates whether this buddy is blocked in the current user's buddies list or not.
A buddy can be blocked by means of a request.
Indicates whether this buddy is online in the Buddy List system or not.
Indicates whether this buddy is temporary (non-persistent) in the current user's buddies list or not.
Returns the custom state of this buddy.
Examples of custom states are "Available", "Busy", "Be right back", etc. If the custom state is not set, null is returned.
The list of available custom states is returned by the IBuddyManager.BuddyStates property.
Returns the nickname of this buddy.
If the nickname is not set, null is returned.
Returns a list of BuddyVariable objects associated with the buddy.
Retrieves a Buddy Variable from its name.
The name of the Buddy Variable to be retrieved.
The object representing the Buddy Variable, or null if no Buddy Variable with the passed name is associated with this buddy.
Indicates whether this buddy has the specified Buddy Variable set or not.
The name of the Buddy Variable whose existance must be checked.
true if a Buddy Variable with the passed name is set for this buddy.
Retrieves the list of persistent Buddy Variables of this buddy.
A list of objects representing the offline Buddy Variables.
Retrieves the list of non-persistent Buddy Variables of this buddy.
A list of objects representing the online Buddy Variables.
The IMMOItem interface defines all the methods and properties that an object representing a SmartFoxServer MMOItem entity exposes.
In the SmartFoxServer 2X client API this interface is implemented by the class. Read the class description for additional informations.
Indicates the id of this item.
The id is unique and it is generated by the server when the item is created.
Retrieves all the MMOItem Variables of this item.
A list of objects representing the MMOItem Variables associated to this item.
Retrieves an MMOItem Variable from its name.
The name of the MMOItem Variable to be retrieved.
The object representing the MMOItem Variable, or null if no MMOItem Variable with the passed name is associated to this item.
Indicates whether this item has the specified MMOItem Variable set or not.
The name of the MMOItem Variable whose existance must be checked.
true if a MMOItem Variable with the passed name is set for this item.
Returns the entry point of this item in the current user's AoI.
The returned coordinates are those that the item had when its presence in the current user's Area of Interest was last notified by a PROXIMITY_LIST_UPDATE event.
This field is populated only if the MMORoom in which the item exists is configured to receive such data.
An MMOItem object represents an active non-player entity inside an MMORoom.
MMOItems can be used to represent bonuses, triggers, bullets, etc, or any other non-player entity that will be handled using the MMORoom's rules of visibility.
This means that whenever one or more MMOItems fall within the Area of Interest of a user, their presence will be notified to that user by means of the
PROXIMITY_LIST_UPDATE event.
MMOItems are identified by a unique ID and can have one or more MMOItem Variables associated to store custom data.
NOTE: MMOItems can be created in a server side Extension only; client side creation is not allowed.
The MMORoom object represents a specialized type of Room entity on the client.
The MMORoom is ideal for huge virtual worlds and MMO games because it works with proximity lists instead of "regular" users lists.
This allows thousands of users to interact with each other based on their Area of Interest (AoI). The AoI represents a range around the user
that is affected by server and user events, outside which no other events are received.
The size of the AoI is set at Room creation time and it is the same for all users who joined it.
Supposing that the MMORoom hosts a 3D virtual world, setting an AoI of (x=100, y=100, z=40) for the Room tells the server to transmit updates and broadcast
events to and from those users that fall within the AoI range around the current user; this means the area within +/- 100 units on the X axis, +/- 100 units on the Y axis and +/- 40 units on the Z axis.
As the user moves around in the virtual environment, he can update his position in the corresponding MMORoom and thus continuously receive events
about other users (and items - see below) entering and leaving his AoI.
The player will be able to update his position via the SetUserPositionRequest request and receive updates on his current proximity list by means of the
PROXIMITY_LIST_UPDATE event.
Finally, MMORooms can also host any number of "MMOItems" which represent dynamic non-player objects that users can interact with.
They are handled by the MMORoom using the same rules of visibility described before.
Returns the default Area of Interest (AoI) of this MMORoom.
Returns the lower coordinates limit of the virtual environment represented by the MMORoom along the X,Y,Z axes.
If null is returned, then no limits were set at Room creation time.
Returns the higher coordinates limit of the virtual environment represented by the MMORoom along the X,Y,Z axes.
If null is returned, then no limits were set at Room creation time.
Retrieves an MMOItem object from its id property.
The item is available to the current user if it falls within his Area of Interest only.
The id of the item to be retrieved.
An MMOItem object, or null if the item with the passed id is not in proximity of the current user.
Retrieves all MMOItem object in the MMORoom that fall within the current user's Area of Interest.
A list of MMOItem objects, or an empty list if no item is in proximity of the current user.
The Room interface defines all the methods and properties that an object representing a SmartFoxServer Room entity exposes.
In the SmartFoxServer 2X client API this interface is implemented by the class. Read the class description for additional informations.
Indicates the id of this Room.
The id is unique and it is generated by the server when the Room is created.
Indicates the name of this Room.
Two Rooms in the same Zone can't have the same name.
NOTE: setting this property manually has no effect on the server and can disrupt the API functioning. Use the request instead.
Returns the Room Group name.
Each Group is identified by a unique string (its name or id) and it represents a different "container" for Rooms.
Room Groups enable developers to organize Rooms under different types or categories and let clients select only those Groups they are interested in,
in order to receive their events only. This is done via the and requests.
The default value is default.
Indicates whether the client joined this Room or not.
NOTE: setting this property manually has no effect on the server and can disrupt the API functioning. Use the request to join a new Room instead.
Indicates whether this is a Game Room or not.
NOTE: setting this property manually has no effect on the server and can disrupt the API functioning. This flag must be set when creating the Room.
Indicates whether this Room is hidden or not.
This is a utility flag that can be used by developers to hide certain Rooms from the interface of their application.
NOTE: setting this property manually has no effect on the server and can disrupt the API functioning. This flag must be set when creating the Room.
Indicates whether this Room requires a password to be joined or not.
NOTE: setting this property manually has no effect on the server and can disrupt the API functioning.
This flag depends on the Room's password set when the Room is created or by means of the request.
Returns the current number of users in this Room.
In case of Game Rooms, this is the number of players.
NOTE: setting this property manually has no effect on the server and can disrupt the API functioning. This flag depends on the Room state.
Returns the maximum number of users allowed in this Room.
In case of Game Rooms, this is the maximum number of players.
NOTE: setting this property manually has no effect on the server and can disrupt the API functioning. This flag must be set when creating the Room.
Returns the current number of spectators in this Room (Game Rooms only).
NOTE: setting this property manually has no effect on the server and can disrupt the API functioning. This flag depends on the Room state.
Returns the maximum number of spectators allowed in this Room (Game Rooms only).
NOTE: setting this property manually has no effect on the server and can disrupt the API functioning. This flag must be set when creating the Game Room.
Returns the maximum amount of users, including spectators, that can be contained in this Room.
Indicates whether the specified user is currently inside this Room or not.
The object representing the user whose presence in this Room must be checked.
true if the user is inside this Room; false otherwise.
Retrieves a User object from its name property.
The name of the user to be found.
The object representing the user, or null if no user with the passed name exists in this Room.
Retrieves a User object from its id property.
The id of the user to be found.
The object representing the user, or null if no user with the passed id exists in this Room.
Returns a list of User objects representing all the users currently inside this Room.
Returns a list of User objects representing the players currently inside this Room (Game Rooms only).
Returns a list of User objects representing the spectators currently inside this Room (Game Rooms only).
Retrieves a Room Variable from its name.
The name of the Room Variable to be retrieved.
The object representing the Room Variable, or null if no Room Variable with the passed name exists in this Room.
Retrieves all the Room Variables of this Room.
A list of objects representing the Room Variables associated with this Room.
Indicates whether this Room has the specified Room Variable set or not.
The name of the Room Variable whose existance in this Room must be checked.
true if a Room Variable with the passed name exists in this Room.
Defines a generic utility object that can be used to store custom Room data.
The values added to this object are for client-side use only and are never transmitted to the server or to the other clients.
Returns a reference to the Room Manager which manages this Room.
NOTE: setting this property manually has no effect on the server and can disrupt the API functioning.
The SFSBuddy object represents a buddy in the current user's buddies list.
A buddy is marked out by the following characteristics.
- Nickname: a buddy can have an optional nickname, which differs from the username used during the login process.
- Online/offline state: users can be online or offline as buddies in the Buddy List system. By default a buddy is online every time he joins a Zone, but the user can also switch the state to offline at runtime, and disappear from other user's buddies list. This state is persistent and it is based on a reserved Buddy Variable.
- Custom state: each user can have a typical IM state such as "Available", "Away", "Occupied", etc. State can be selected among the custom ones defined in the Zone configuration, which can be changed or enriched at any time. This state is persistent and it is based on a reserved Buddy Variable.
- Blocked buddy: buddies that are blocked in a user's buddies list won't be able to send messages to that user; also they won't be able to see if the user is online or offline in the Buddy List system.
- Temporary buddy: a temporary buddy is added to the current user's buddies list whenever another user adds him to his own buddies list. In this way users can "see" each other and exchange messages. If the current user doesn't add that temporary buddy to his buddies list voluntarily, that buddy won't be persisted and will be lost upon disconnection.
- Variables: Buddy Variables enable each user to show (and send updates on) specific custom informations to each user to whom he is a buddy. For example one could send realtime updates on his last activity, or post the title of the song he's listening right now, or scores, rankings and whatnot.
Returns a string that contains the buddy name and id.
The string representation of the object.
The SFSRoom object represents a SmartFoxServer Room entity on the client.
The SmartFoxServer 2X client API are not aware of all the Rooms which exist on the server side, but only of those that are joined by the user
and those in the Room Groups that have been subscribed. Subscribing to one or more Groups allows the client to listen to Room events in specific "areas" of the Zone,
without having to retrieve and keep synchronized the details of all available Rooms, thus reducing the traffic between the client and the server considerably.
The list of available Rooms is created after a successful login and it is kept updated continuously by the server.
Returns a string that contains the Room id, name and id of the Group to which it belongs.
The string representation of the object.
The SFSUser object represents a client logged in SmartFoxServer.
The SmartFoxServer 2X client API are not aware of all the clients (users) connected to the server, but only of those that are in the same Rooms joined by the current client;
this reduces the traffic between the client and the server considerably. In order to interact with other users the client should join other Rooms
or use the Buddy List system to keep track of and interact with friends.
Returns a string that contains the user id, name and a boolean indicating if the this object represents the current client.
The string representation of the object.
The User interface defines all the methods and properties that an object representing a SmartFoxServer User entity exposes.
In the SmartFoxServer 2X client API this interface is implemented by the class. Read the class description for additional informations.
Indicates the id of this user.
The id is unique and it is generated by the server when the user is created.
Indicates the name of this user.
Two users in the same Zone can't have the same name.
Returns the id of this user as a player in a Game Room.
This property differs from property and it used to indicate which player number is assigned to a user inside a Game Room.
For example, in a Game Room for 5 players the first client joining it will have its playerId equal to 1, the second will have it equal to 2 and so forth.
When a user leaves the Room the player slot is freed up and the next user joining the Room will take it.
This property applies to Game Rooms only; in standard Rooms it is always 0. Also, in Game Rooms a playerId value lower than 0 indicates that the user is a spectator.
If the user is inside multiple Game Rooms at the same time, a different playerId value will be assigned to him in each Room.
In this case this property returns the value corresponding to the last joined Room; in order to obtain the playerId value in a specific Room, use the method.
Indicates whether this user is a player (playerId greater than 0) in the last joined Room or not.
Non-Game Rooms always return false.
If the user is inside multiple Game Rooms at the same time, use the method.
Indicates whether this user is a spectator (playerId lower than 0) in the last joined Room or not.
Non-Game Rooms always return false.
If the user is inside multiple Game Rooms at the same time, use the method.
Returns the playerId value of this user in the passed Room.
See the property description for more informations.
The object representing the Room to retrieve the player id from.
The player id of this user in the passed Room.
Returns the id which identifies the privilege level of this user.
NOTE: setting this property manually has no effect on the server and can disrupt the API functioning. Privileges are assigned to the user by the server when the user logs in.
Returns a reference to the User Manager which manages this user.
NOTE: setting this property manually has no effect on the server and can disrupt the API functioning.
Indicates whether this user logged in as a guest or not.
Guest users have this property set to .
true if this user is a guest.
Indicates whether this user logged in as a standard user or not.
Standard users have this property set to .
true if this user is a standard user.
Indicates whether this user logged in as a moderator or not.
Moderator users have this property set to .
true if this user is a moderator.
Indicates whether this user logged in as an administrator or not.
Administrator users have this property set to .
true if this user is an administrator.
Indicates whether this user is a player (playerId greater than 0) in the passed Room or not.
Non-Game Rooms always return false.
If a user can join one Game Room at a time only, use the property.
The object representing the Room where to check if this user is a player.
true if this user is a player in the passed Room.
Indicates whether this user is a spectator (playerId lower than 0) in the passed Room or not.
Non-Game Rooms always return false.
If a user can join one Game Room at a time only, use the property.
The object representing the Room where to check if this user is a spectator.
true if this user is a spectator in the passed Room.
Indicates whether this user joined the passed Room or not.
The object representing the Room where to check the user presence.
true if this user is inside the passed Room.
Indicates if this User object represents the current client.
Retrieves all the User Variables of this user.
A list of objects representing the User Variables associated with this user.
Retrieves a User Variable from its name.
The name of the User Variable to be retrieved.
The object representing the User Variable, or null if no User Variable with the passed name is associated with this user.
Indicates whether this user has the specified User Variable set or not.
The name of the User Variable whose existance must be checked.
true if a User Variable with the passed name is set for this user.
Defines a generic utility object that can be used to store custom user data.
The values added to this object are for client-side use only and are never transmitted to the server or to the other clients.
Returns the entry point of this user in the current user's AoI.
The returned coordinates are those that the user had when his presence in the current user's Area of Interest was last notified by a PROXIMITY_LIST_UPDATE event.
This field is populated only if the user joined a Room of type MMORoom and this is configured to receive such data from the server.
This class contains the costants describing the default user types known by SmartFoxServer.
The server assigns one of these values or a custom-defined one to the User.PrivilegeId property whenever a user logs in.
Read the SmartFoxServer 2X documentation for more informations about privilege profiles and their permissions.
The Guest user is usually the lowest level in the privilege profiles scale.
The standard user is usually registered in the application custom login system; uses a unique name and password to login.
The moderator user can send dedicated "moderator messages", kick and ban users.
The administrator user can send dedicated "administrator messages", kick and ban users.
The ISFSArray interface defines all the public methods and properties of the SFSArray class used by SmartFoxServer in client-server data transfer.
Read the implementor class description for additional informations.
Check the enumeration for more informations on supported data types.
Indicates whether this array contains the specified object or not.
The object whose presence in this array is to be tested.
true if the specified object is present.
Returns the element at the specified position in this array.
The position of the element to return.
The element at the specified index in this array.
Removes the element at the specified position in this array.
The position of the element to be removed.
The element that was removed.
Indicates the number of elements in this array.
The number of elements in this array.
Provides the binary form of this array.
The binary data representing this array.
Provides the JSON representation of this array.
This method is not available in Windows / Windows Phone.
The JSON string representing this array.
This method is not available in Windows 8 / Windows Phone 8.
Provides a formatted string representing this array.
The returned string can be logged or traced in the console for debugging purposes.
If true, the output is formatted in a human-readable way.
The string representation of this array.
See .
Provides a detailed hexadecimal representation of this array.
The returned string can be logged or traced in the console for debugging purposes.
The hexadecimal string representation of this array.
Appends a null value to the end of this array.
Appends a boolean value to the end of this array.
The value to be appended to this array.
Appends a byte (8 bits) value to the end of this array.
The value to be appended to this array.
Appends a short integer (16 bits) value to the end of this array.
The value to be appended to this array.
Appends an integer (32 bits) value to the end of this array.
The value to be appended to this array.
Appends a long integer (64 bits) value to the end of this array.
The value to be appended to this array.
Appends a floating point number (32 bits) value to the end of this array.
The value to be appended to this array.
Appends a double precision number (64 bits) value to the end of this array.
The value to be appended to this array.
Appends a UTF-8 string (with max length of 32 KBytes) value to the end of this array.
The value to be appended to this array.
Appends a UTF-8 string (with max length of 2 GBytes) value to the end of this array.
The value to be appended to this array.
Appends an array of boolean values to the end of this array.
The array of booleans to be appended to this array.
Appends a ByteArray object to the end of this array.
IMPORTANT: ByteArrays transmission is not supported in Unity WebGL.
The ByteArray object to be appended to this array.
Appends an array of short integer values to the end of this array.
The array of shorts to be appended to this array.
Appends an array of integer values to the end of this array.
The array of ints to be appended to this array.
Appends an array of long integer values to the end of this array.
The array of longs to be appended to this array.
Appends an array of floating point number values to the end of this array.
The array of floats to be appended to this array.
Appends an array of double precision number values to the end of this array.
The array of doubles to be appended to this array.
Appends an array of UTF-8 string values to the end of this array.
The array of strings to be appended to this array.
Appends an ISFSArray object to the end of this array.
The object implementing the ISFSArray interface to be appended to this array.
Appends a ISFSObject object to the end of this array.
The object implementing the ISFSObject interface to be appended to this array.
Appends the passed custom class instance to the end of this array.
Read the method description for more informations.
IMPORTANT: class serialization is not supported in Unity WebGL.
The custom class instance to be appended to this array.
Indicates if the element at the specified position in this array is null.
The position of the element to be checked.
true if the element of this array at the specified position is null.
Returns the element at the specified position as a boolean.
The position of the element to return.
The element of this array at the specified index.
Returns the element at the specified position as a signed byte (8 bits).
The position of the element to return.
The element of this array at the specified index.
Returns the element at the specified position as a short integer (16 bits).
The position of the element to return.
The element of this array at the specified index.
Returns the element at the specified position as an integer (32 bits).
The position of the element to return.
The element of this array at the specified index.
Returns the element at the specified position as a long integer (64 bits).
The position of the element to return.
The element of this array at the specified index.
Returns the element at the specified position as a floating point number.
The position of the element to return.
The element of this array at the specified index.
Returns the element at the specified position as a double precision number.
The position of the element to return.
The element of this array at the specified index.
Returns the element at the specified position as an UTF-8 string, with max length of 32 KBytes.
The position of the element to return.
The element of this array at the specified index.
Returns the element at the specified position as an UTF-8 string, with max length of 2 GBytes.
The position of the element to return.
The element of this array at the specified index.
Returns the element at the specified position as an array of booleans.
The position of the element to return.
The element of this array as an array of booleans.
Returns the element at the specified position as a ByteArray object.
IMPORTANT: ByteArrays transmission is not supported in Unity WebGL.
The position of the element to return.
The element of this array as a ByteArray object.
Returns the element at the specified position as an array of shorts.
The position of the element to return.
The element of this array as an array of shorts.
Returns the element at the specified position as an array of integers.
The position of the element to return.
The element of this array as an array of integers.
Returns the element at the specified position as an array of longs.
The position of the element to return.
The element of this array as an array of longs.
Returns the element at the specified position as an array of floats.
The position of the element to return.
The element of this array as an array of floats.
Returns the element at the specified position as an array of doubles.
The position of the element to return.
The element of this array as an array of doubles.
Returns the element at the specified position as an array of UTF-8 strings.
The position of the element to return.
The element of this array as an array of UTF-8 strings.
Returns the element at the specified position as an ISFSArray object.
The position of the element to return.
The element of this array as an object implementing the ISFSArray interface.
Returns the element at the specified position as an ISFSObject object.
The position of the element to return.
The element of this array as an object implementing the ISFSObject interface.
Returns the element at the specified position as an instance of a custom class.
This advanced feature allows the transmission of specific object instances between client-side C# and server-side Java provided that:
- the respective class definitions on both sides have the same package name
- the class implements the SerializableSFSType interface on both sides
- the following code is executed right after creating the SmartFox object: DefaultSFSDataSerializer.RunningAssembly = Assembly.GetExecutingAssembly(); (requires System.Reflection and Sfs2X.Protocol.Serialization)
IMPORTANT: class serialization is not supported in Unity WebGL.
The position of the element to return.
The element of this array as a generic object type to be casted to the target class definition.
The following example shows the same class on the client and server sides, which can be transferred back and forth with the and methods.
The server-side Java definition of a SpaceShip class is:
package my.game.spacecombat
public class SpaceShip implements SerializableSFSType
{
private String type;
private String name;
private int firePower;
private int maxSpeed;
private List<String> weapons;
public SpaceShip(String name, String type)
{
this.name = name;
this.type = type;
}
// ... Getters / Setters ...
}
The client-side C# definition of the SpaceShip class is:
namespace my.game.spacecombat
{
public class SpaceShip : SerializableSFSType
{
private string _type;
private string _name;
private int _firePower;
private int _maxSpeed;
private Array _weapons;
public SpaceShip(string name, string type)
{
_name = name
_type = type
}
// ... Getters / Setters ...
}
}
A SpaceShip instance is sent by the server to the client in the first position of an array. This is how to retrieve it:
SpaceShip myShipData = (SpaceShip)sfsArray.GetClass(0);
The ISFSObject interface defines all the public methods and properties of the SFSObject class used by SmartFoxServer in client-server data transfer.
Read the implementor class description for additional informations.
Check the enumeration for more informations on supported data types.
Indicates if the value mapped by the specified key is null.
The key to be checked.
true if the value mapped by the passed key is null or the mapping doesn't exist for that key.
Indicates whether this object contains a mapping for the specified key or not.
The key whose presence in this object is to be tested.
true if this object contains a mapping for the specified key.
Removes the element corresponding to the passed key from this object.
The key of the element to be removed.
Retrieves a list of all the keys contained in this object.
The list of all the keys in this object.
Indicates the number of elements in this object.
The number of elements in this object.
Provides the binary form of this object.
The binary data representing this object.
Provides the JSON representation of this object.
This method is not available in Windows / Windows Phone.
The JSON string representing this object.
This method is not available in Windows 8 / Windows Phone 8.
Provides a formatted string representing this object.
The returned string can be logged or traced in the console for debugging purposes.
If true, the output is formatted in a human-readable way.
The string representation of this object.
See .
Provides a detailed hexadecimal representation of this object.
The returned string can be logged or traced in the console for debugging purposes.
The hexadecimal string representation of this object.
Returns the element corresponding to the specified key as a boolean.
The key whose associated value is to be returned.
The element of this object associated with the specified key; false if a mapping for the passed key doesn't exist.
Returns the element corresponding to the specified key as a signed byte (8 bits).
The key whose associated value is to be returned.
The element of this object associated with the specified key; 0 if a mapping for the passed key doesn't exist.
Returns the element corresponding to the specified key as a short integer (16 bits).
The key whose associated value is to be returned.
The element of this object associated with the specified key; 0 if a mapping for the passed key doesn't exist.
Returns the element corresponding to the specified key as an integer (32 bits).
The key whose associated value is to be returned.
The element of this object associated with the specified key; 0 if a mapping for the passed key doesn't exist.
Returns the element corresponding to the specified key as a long integer (64 bits).
The key whose associated value is to be returned.
The element of this object associated with the specified key; 0 if a mapping for the passed key doesn't exist.
Returns the element corresponding to the specified key as a floating point number.
The key whose associated value is to be returned.
The element of this object associated with the specified key; 0 if a mapping for the passed key doesn't exist.
Returns the element corresponding to the specified key as a double precision number.
The key whose associated value is to be returned.
The element of this object associated with the specified key; 0 if a mapping for the passed key doesn't exist.
Returns the element corresponding to the specified key as an UTF-8 string, with max length of 32 KBytes.
The key whose associated value is to be returned.
The element of this object associated with the specified key; null if a mapping for the passed key doesn't exist.
Returns the element corresponding to the specified key as an UTF-8 string, with max length of 2 GBytes.
The key whose associated value is to be returned.
The element of this object associated with the specified key; null if a mapping for the passed key doesn't exist.
Returns the element corresponding to the specified key as an array of booleans.
The key whose associated value is to be returned.
The element of this object as an array of booleans; null if a mapping for the passed key doesn't exist.
Returns the element corresponding to the specified key as a ByteArray object.
IMPORTANT: ByteArrays transmission is not supported in Unity WebGL.
The key whose associated value is to be returned.
The element of this object as a ByteArray object; null if a mapping for the passed key doesn't exist.
Returns the element corresponding to the specified key as an array of shorts.
The key whose associated value is to be returned.
The element of this object as an array of shorts; null if a mapping for the passed key doesn't exist.
Returns the element corresponding to the specified key as an array of integers.
The key whose associated value is to be returned.
The element of this object as an array of integers; null if a mapping for the passed key doesn't exist.
Returns the element corresponding to the specified key as an array of longs.
The key whose associated value is to be returned.
The element of this object as an array of longs; null if a mapping for the passed key doesn't exist.
Returns the element corresponding to the specified key as an array of floats.
The key whose associated value is to be returned.
The element of this object as an array of floats; null if a mapping for the passed key doesn't exist.
Returns the element corresponding to the specified key as an array of doubles.
The key whose associated value is to be returned.
The element of this object as an array of doubles; null if a mapping for the passed key doesn't exist.
Returns the element corresponding to the specified key as an array of UTF-8 strings.
The key whose associated value is to be returned.
The element of this object as an array of UTF-8 strings; null if a mapping for the passed key doesn't exist.
Returns the element corresponding to the specified key as an ISFSArray object.
The key whose associated value is to be returned.
The element of this object as an object implementing the ISFSArray interface; null if a mapping for the passed key doesn't exist.
Returns the element corresponding to the specified key as an ISFSObject object.
The key whose associated value is to be returned.
The element of this object as an object implementing the ISFSObject interface; null if a mapping for the passed key doesn't exist.
Returns the element corresponding to the specified key as an instance of a custom class.
This advanced feature allows the transmission of specific object instances between client-side C# and server-side Java provided that:
- the respective class definitions on both sides have the same package/namespace name
- the class implements the SerializableSFSType interface on both sides
- the following code is executed right after creating the SmartFox object: DefaultSFSDataSerializer.RunningAssembly = Assembly.GetExecutingAssembly(); (requires System.Reflection and Sfs2X.Protocol.Serialization)
IMPORTANT: class serialization is not supported in Unity WebGL.
The key whose associated value is to be returned.
The element of this object as a generic object type to be casted to the target class definition; null if a mapping for the passed key doesn't exist.
The following example shows the same class on the client and server sides, which can be transferred back and forth with the and methods.
The server-side Java definition of a SpaceShip class is:
package my.game.spacecombat
public class SpaceShip implements SerializableSFSType
{
private String type;
private String name;
private int firePower;
private int maxSpeed;
private List<String> weapons;
public SpaceShip(String name, String type)
{
this.name = name;
this.type = type;
}
// ... Getters / Setters ...
}
The client-side C# definition of the SpaceShip class is:
namespace my.game.spacecombat
{
public class SpaceShip : SerializableSFSType
{
private string _type;
private string _name;
private int _firePower;
private int _maxSpeed;
private Array _weapons;
public SpaceShip(string name, string type)
{
_name = name
_type = type
}
// ... Getters / Setters ...
}
}
The SpaceShip instance is sent by the server to the client. This is how to retrieve it:
SpaceShip myShipData = (SpaceShip)sfsObject.GetClass(key);
Associates the passed boolean value with the specified key in this object.
The key with which the specified value is to be associated.
The value to be associated with the specified key.
Associates the passed byte value with the specified key in this object.
The key with which the specified value is to be associated.
The value to be associated with the specified key.
Associates the passed short value with the specified key in this object.
The key with which the specified value is to be associated.
The value to be associated with the specified key.
Associates the passed integer value with the specified key in this object.
The key with which the specified value is to be associated.
The value to be associated with the specified key.
Associates the passed long value with the specified key in this object.
The key with which the specified value is to be associated.
The value to be associated with the specified key.
Associates the passed float value with the specified key in this object.
The key with which the specified value is to be associated.
The value to be associated with the specified key.
Associates the passed double value with the specified key in this object.
The key with which the specified value is to be associated.
The value to be associated with the specified key.
Associates the passed UTF-8 string value (max length: 32 KBytes) with the specified key in this object.
The key with which the specified value is to be associated.
The value to be associated with the specified key.
Associates the passed UTF-8 string value (max length: 2 GBytes) with the specified key in this object.
The key with which the specified value is to be associated.
The value to be associated with the specified key.
Associates the passed array of booleans with the specified key in this object.
The key with which the specified array is to be associated.
The array of booleans to be associated with the specified key.
Associates the passed ByteArray object with the specified key in this object.
IMPORTANT: ByteArrays transmission is not supported in Unity WebGL.
The key with which the specified object is to be associated.
The object to be associated with the specified key.
Associates the passed array of shorts with the specified key in this object.
The key with which the specified array is to be associated.
The array of shorts to be associated with the specified key.
Associates the passed array of integers with the specified key in this object.
The key with which the specified array is to be associated.
The array of integers to be associated with the specified key.
Associates the passed array of longs with the specified key in this object.
The key with which the specified array is to be associated.
The array of longs to be associated with the specified key.
Associates the passed array of floats with the specified key in this object.
The key with which the specified array is to be associated.
The array of floats to be associated with the specified key.
Associates the passed array of doubles with the specified key in this object.
The key with which the specified array is to be associated.
The array of doubles to be associated with the specified key.
Associates the passed array of UTF-8 strings with the specified key in this object.
The key with which the specified array is to be associated.
The array of UTF-8 strings to be associated with the specified key.
Associates the passed ISFSArray object with the specified key in this object.
The key with which the specified object is to be associated.
The object to be associated with the specified key.
Associates the passed ISFSObject object with the specified key in this object.
The key with which the specified object is to be associated.
The object to be associated with the specified key.
Associates the passed custom class instance with the specified key in this object.
Read the method description for more informations.
IMPORTANT: class serialization is not supported in Unity WebGL.
The key with which the specified custom class instance is to be associated.
The custom class instance to be associated with the specified key.
The SFSArray class is used by SmartFoxServer in client-server data transfer.
This class can be thought of as a specialized Array/List object that can contain any type of data.
The advantage of using the SFSArray class (for example as a nested object inside a object) is that you can fine tune the way your data is transmitted over the network.
For instance, when transmitting a list of numbers between 0 and 100, those values can be treated as normal integers (which take 32 bits each), but also as shorts (16 bit) or even as bytes (8 bit).
SFSArray supports many primitive data types and related arrays of primitives (see the class). It also allows to serialize class instances and rebuild them on the other side (client or server).
Check the SmartFoxServer 2X documentation for more informations on this advanced topic.
Returns a new SFSArray instance.
This is an alternative static constructor that builds an SFSArray from a valid SFSArray binary representation.
The ByteArray representation of a SFSArray.
A new SFSArray instance.
Returns a new ISFSArray instance.
This is an alternative static constructor that builds an ISFSArray from a valid JSON string representation.
This method is not available in Windows / Windows Phone.
The JSON representation of a SFSArray.
A new ISFSArray instance.
Returns a new SFSArray instance.
This method is a static alternative to the standard class constructor.
A new SFSArray instance.
Returns a new SFSArray instance.
Checking if this object contains an inner SFSObject or SFSArray is not supported.
The "lite" version of SFSObject, supporting proper type conversions for dynamic languages such as JavaScript.
The SFSDataType class contains the costants defining the data types supported by SFSObject and SFSArray classes.
Null value.
Boolean.
Byte, signed 8 bits.
Short integer, signed 16 bits.
Integer, signed 32 bits.
Long integer, signed 64 bits.
Floating point decimal, signed 32 bits.
Double precision decimal, signed 64 bits.
UTF-8 encoded string, with length up to 32 KBytes.
Array of booleans.
Array of bytes (treated as ByteArray).
Array of shorts.
Array of integers.
Array of long integers.
Array of floats.
Array of Doubles.
Array of UTF-8 strings.
SFSArray.
SFSObject.
Serialized class instance.
UTF-8 encoded string, with length up to 2 GBytes.
A wrapper object used by SFSObject and SFSArray to encapsulate data and relative types
The SFSObject class is used by SmartFoxServer in client-server data transfer.
This class can be thought of as a specialized Dictionary/Map object that can contain any type of data.
The advantage of using the SFSObject class (for example when sending an request) is that you can fine tune the way your data is transmitted over the network.
For instance, a number like 100 can be transmitted as a normal integer (which takes 32 bits), but also a short (16 bit) or even a byte (8 bit).
SFSObject supports many primitive data types and related arrays of primitives (see the class). It also allows to serialize class instances and rebuild them on the other side (client or server).
Check the SmartFoxServer 2X documentation for more informations on this advanced topic.
Returns a new SFSObject instance.
This is an alternative static constructor that builds an SFSObject from a valid SFSObject binary representation.
The ByteArray representation of a SFSObject.
A new SFSObject instance.
Returns a new ISFSObject instance.
This is an alternative static constructor that builds an ISFSObject from a valid JSON string representation.
This method is not available in Windows / Windows Phone.
The JSON representation of a SFSObject.
A new ISFSObject instance.
Returns a new SFSObject instance.
This method is a static alternative to the standard class constructor.
A new SFSObject instance.
Returns a new SFSObject instance.
The "lite" version of SFSObject, supporting proper type conversions for dynamic languages such as JavaScript.
The Vec3D object represents a position in a 2D or 3D space.
This class is used to express a position inside a virtual environment with no specific unit of measure (could be pixels, feet, meters, etc).
Positions along the X,Y,Z axes can be expressed as Integers or Floats, based on the game's coordinate system requirements.
Creates a new Vec3D instance for a 3D coordinates system with integer values.
The position along the X axis.
The position along the Y axis.
The position along the Z axis.
Creates a new Vec3D instance for a 2D coordinates system with integer values.
The position along the X axis.
The position along the Y axis.
Creates a new Vec3D instance for a 3D coordinates system with float values.
The position along the X axis.
The position along the Y axis.
The position along the Z axis.
Creates a new Vec3D instance for a 2D coordinates system with float values.
The position along the X axis.
The position along the Y axis.
Indicates whether the position is expressed using floating point values or not.
true if the position is expressed using floating point values.
Returns the position along the X axis as a float value.
Returns the position along the Y axis as a float value.
Returns the position along the Z axis as a float value.
Returns the position along the X axis as an integer value.
Returns the position along the Y axis as an integer value.
Returns the position along the Z axis as an integer value.
The Invitation interface defines all the methods and properties that an object representing an invitation entity exposes.
In the SmartFoxServer 2X client API this interface is implemented by the class. Read the class description for additional informations.
Indicates the id of this invitation.
It is generated by the server when the invitation is sent.
NOTE: setting the id property manually has no effect on the server and can disrupt the API functioning.
Returns the User object corresponding to the user who sent the invitation.
Returns the User object corresponding to the user who received the invitation.
Returns the number of seconds available to the invitee to reply to the invitation, after which the invitation expires.
Returns an instance of SFSObject containing a custom set of parameters.
This usually stores invitation details, like a message to the invitee and any other relevant data.
The InvitationReply enumeration contains the costants describing the possible replies to an invitation.
Invitation is accepted.
Invitation is refused.
Invitation expired.
The SFSInvitation object contains all the informations about an invitation received by the current user.
An invitation is sent through the request and it is received as an invitation event.
Clients can reply to an invitation using the request.
The id is only used when the Invitation is built from a Server Side Invitation
The IBuddyManager interface defines all the methods and properties exposed by the client-side manager of the SmartFoxServer Buddy List system.
In the SmartFoxServer 2X client API this interface is implemented by the class. Read the class description for additional informations.
Indicates whether the client's Buddy List system is initialized or not.
If not initialized, an request should be sent to the server in order to retrieve the persistent Buddy List data.
Indicates whether a buddy exists in user's buddies list or not.
The name of the buddy whose presence in the buddies list is to be tested.
true if the specified buddy exists in the buddies list.
Retrieves a Buddy object from its id property.
The id of the buddy to be found.
The object representing the buddy, or null if no buddy with the passed id exists in the buddies list.
Retrieves a Buddy object from its name property.
The name of the buddy to be found.
The object representing the buddy, or null if no buddy with the passed name exists in the buddies list.
Retrieves a Buddy object from its nickName property (if set).
The nickName of the buddy to be found.
The object representing the buddy, or null if no buddy with the passed nickName exists in the buddies list.
Returns a list of Buddy objects representing all the offline buddies in the user's buddies list.
Returns a list of Buddy objects representing all the online buddies in the user's buddies list.
Returns a list of Buddy objects representing all the buddies in the user's buddies list.
The list is null if the Buddy List system is not initialized.
Returns a list of strings representing the available custom buddy states.
The custom states are received by the client upon initialization of the Buddy List system. They can be configured by means of the SmartFoxServer 2X Administration Tool.
Retrieves a Buddy Variable from its name.
The name of the Buddy Variable to be retrieved.
The object representing the Buddy Variable, or null if no Buddy Variable with the passed name is associated with the current user.
Returns all the Buddy Variables associated with the current user.
Returns the current user's online/offline state.
If true, the user appears to be online in the buddies list of other users who have him as a buddy.
The online state of a user in a buddy list is handled by means of a reserved Buddy Variable (see class);
it can be changed using the dedicated request.
Returns the current user's nickname (if set).
If the nickname was never set before, null is returned.
As the nickname of a user in a buddy list is handled by means of a reserved Buddy Variable (see class),
it can be set using the request.
Returns the current user's custom state (if set).
Examples of custom states are "Available", "Busy", "Be right back", etc. If the custom state was never set before, null is returned.
As the custom state of a user in a buddy list is handled by means of a reserved Buddy Variable (see class),
it can be set using the request.
The IRoomManager interface defines all the methods and properties exposed by the client-side manager of the SmartFoxServer Room entities.
In the SmartFoxServer 2X client API this interface is implemented by the class. Read the class description for additional informations.
Indicates whether the specified Group has been subscribed by the client or not.
The name of the Group.
true if the client subscribed the passed Group.
Indicates whether a Room exists in the Rooms list or not.
The id or name of the Room object whose presence in the Rooms list is to be tested.
true if the passed Room exists in the Rooms list.
Indicates whether the Rooms list contains a Room belonging to the specified Group or not.
The id or name of the Room object whose presence in the Rooms list is to be tested.
The name of the Group to which the specified Room must belong.
true if the Rooms list contains the passed Room and it belongs to the specified Group.
Retrieves a Room object from its id.
The id of the Room.
An object representing the requested Room; null if no Room object with the passed id exists in the Rooms list.
Retrieves a Room object from its name.
The name of the Room.
An object representing the requested Room; null if no Room object with the passed name exists in the Rooms list.
Returns a list of Rooms currently "known" 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.
At login time, the client automatically subscribes all the Room Groups specified in the Zone's Default Room Groups setting.
The list of the available Room objects.
Returns the current number of Rooms in the Rooms list.
The number of Rooms in the Rooms list.
Returns the names of Groups currently subscribed by the client.
At login time, the client automatically subscribes all the Room Groups specified in the Zone's Default Room Groups setting.
A list of Group names.
Retrieves the list of Rooms which are part of the specified Room Group.
The name of the Group.
The list of Room objects belonging to the passed Group.
Returns a list of Rooms currently joined by the client.
The list of objects representing the Rooms currently joined by the client.
Retrieves a list of Rooms joined by the specified user.
The list contains only those Rooms "known" by the Room Manager; the user might have joined others the client is not aware of.
The object representing the user to look for in the current Rooms list.
The list of Rooms joined by the passed user.
The IUserManager interface defines all the methods and properties exposed by the client-side manager of the SmartFoxServer User entities.
In the SmartFoxServer 2X client API this interface is implemented by the class. Read the class description for additional informations.
Indicates whether a user exists in the local users list or not from the name.
The name of the user whose presence in the users list is to be tested.
true if a user with the passed name exists in the users list.
Indicates whether a user exists in the local users list or not from the id.
The id of the user whose presence in the users list is to be tested.
true if a user corresponding to the passed id exists in the users list.
Indicates whether a user exists in the local users list or not.
The object representing the user whose presence in the users list is to be tested.
true if the passed user exists in the users list.
Retrieves a User object from its name property.
The name of the user to be found.
The object representing the user, or null if no user with the passed name exists in the local users list.
Retrieves a User object from its id property.
The id of the user to be found.
The object representing the user, or null if no user with the passed id exists in the local users list.
Returns the total number of users in the local users list.
Get the whole list of users inside the Rooms joined by the client.
The list of User objects representing the users in the local users list.
The SFSBuddyManager class is the entity in charge of managing the current user's Buddy List system.
This manager keeps track of all the user's buddies, their state and their Buddy Variables. It also provides utility methods to set the user's properties when he is part of the buddies list of other users.
Initializes a new instance of the class.
Sfs.
Initializes a new instance of the class.
Room.
Does not allow duplicates and keeps a reference count
A
Removes the user.
User.
The SFSRoomManager class is the entity in charge of managing the client-side Rooms list.
This manager keeps track of all the Rooms available in the client-side Rooms list and of subscriptions to multiple Room Groups. It also provides various utility methods to look for Rooms by name and id, retrieve Rooms belonging to a specific Group, etc.
The SFSUserManager class is the entity in charge of managing the local (client-side) users list.
This manager keeps track of all the users that are currently joined in the same Rooms of the current user. It also provides utility methods to look for users by name and id.
The BoolMatch class is used in matching expressions to check boolean conditions.
An instance of BoolMatch representing the following condition: bool1 == bool2.
An instance of BoolMatch representing the following condition: bool1 != bool2.
The IMatcher interface defines the properties that an object representing a condition to be used in a matching expression exposes.
Returns the condition symbol of this matcher.
Returns the type id of this matcher.
The LogicOperator class is used to concatenate two matching expressions using the AND or OR logical operator.
An instance of LogicOperator representing the AND logical operator.
An instance of LogicOperator representing the OR logical operator.
Returns the id of the current LogicOperator instance. It can be the string "AND" or "OR".
The MatchExpression class represents a matching expression used to compare custom variables or predefined properties when searching for users or Rooms.
The matching expressions are built like "if" statements in any common programming language. They work like queries in a database and can be used to search for Rooms
or users using custom criteria: in fact a matching expression can compare predefined properties of the Room and user entities
(see the and classes),but also custom Room or User Variables.
These expressions are easy to create and concatenate, and they can be used for many different filtering operations within the SmartFoxServer 2X framework,
for example to invite players to join a game (see the request description),
to look for specific Rooms or users (see the and requests descriptions), etc.
Additionally (see the examples for more informations):
- any number of expressions can be linked together with the logical AND and OR operators to create complex queries;
- searching through nested data structures such as and can be done via a very simple dot-syntax.
The following example shows how to create a simple matching expression made of two concatenated conditions: it compares the custom "rank" and "country"
User Variables to the passed values. This expression could be used during the creation of a Game Room, to filter the users that the server should take
into account when sending the invitations to join the game (only italian users with a ranking greater than 5 - whatever this number means to our game):
MatchExpression exp = new MatchExpression('rank', NumberMatch.GREATER_THAN, 5).And('country', StringMatch.EQUALS, 'Italy');
The following example creates a matching expression made of three concatenated conditions which compare two predefined Room properties and the custom "isGameStarted"
Room Variable to the passed values; this expression could be used to retrieve all the Game Rooms still waiting for players to join them:
MatchExpression exp = new MatchExpression(RoomProperties.IS_GAME, BoolMatch.EQUALS, true)
.And(RoomProperties.HAS_FREE_PLAYER_SLOTS, BoolMatch.EQUALS, true)
.And("isGameStarted", BoolMatch.EQUALS, false);
The following example creates a matching expression which compares a nested property in a complex data structure; an SFSObject called "avatarData" (could be a User Variable for example)
contains the "shield" object (a nested SFSObject) which in turn contains, among others, the "inUse" property which could be used to retrieve all user
whose avatars are currently equipped with a shield:
MatchExpression exp = new MatchExpression("avatarData.shield.inUse", BoolMatch.EQUALS, true);
The following example is similar to the previous one, but it involves an SFSArray. The "avatarData" object contains the "weapons" SFSArray, from which the expression retrieves
the third element (that .3 means "give me the element at index == 3") that we know being the weapon the user avatar has in his right hand. Again, this element is an SFSObject containing,
among the others, the "name" property which can be compared to the passed string. This example could be used to retrieve all users whose avatars have the Narsil sword in the right hand:
MatchExpression exp = new MatchExpression("avatarData.weapons.3.name", StringMatch.EQUALS, "Narsil");
Creates a new MatchExpression instance.
Name of the variable or property to match.
The matching condition.
The value to compare against the variable or property during the matching.
Concatenates the current expression with a new one using the logical AND operator.
The name of the additional variable or property to match.
The additional matching condition.
The value to compare against the additional variable or property during the matching.
A new MatchExpression resulting from the concatenation of the current expression with a new one generated from the specified parameters.
Concatenates the current expression with a new one using the logical OR operator.
The name of the additional variable or property to match.
The additional matching condition.
The value to compare against the additional variable or property during the matching.
A new MatchExpression resulting from the concatenation of the current expression with a new one generated from the specified parameters.
Returns the name of the variable or property against which the comparison is made.
Depending what the matching expression is used for (searching a or a ),
this can be the name of a or a ,
or it can be one of the constants contained in the or classes,
representing some of the predefined properties of the user and Room entities respectively.
Returns the matching criteria used during values comparison.
Different objects implementing the interface can be used, depending on the type of the variable or property to check.
Returns the value against which the variable or property corresponding to varName is compared.
In case of concatenated expressions, returns the current logical operator.
The default value is null.
Checks if the current matching expression is concatenated to another one through a logical operator.
true if the current matching expression is concatenated to another one.
Get the next matching expression concatenated to the current one.
The next expression concatenated to the current one.
Moves the iterator cursor to the first matching expression in the chain.
The MatchExpression object at the top of the chain of matching expressions.
Returns a string representation of the matching expression.
A string that represents the current .
The NumberMatch class is used in matching expressions to check numeric conditions.
An instance of NumberMatch representing the following condition: number1 == number2.
An instance of NumberMatch representing the following condition: number1 != number2.
An instance of NumberMatch representing the following condition: number1 > number2.
An instance of NumberMatch representing the following condition: number1 >= number2.
An instance of NumberMatch representing the following condition: number1 < number2.
An instance of NumberMatch representing the following condition: number1 <= number2.
The RoomProperties class contains the names of predefined properties that can be used in matching expressions to search/filter Rooms.
The Room name.
Requires a to be used for values comparison.
The name of the Group to which the Room belongs.
Requires a to be used for values comparison.
The maximum number of users allowed in the Room (players in Game Rooms).
Requires a to be used for values comparison.
The maximum number of spectators allowed in the Room (Game Rooms only).
Requires a to be used for values comparison.
The Room users count (players in Game Rooms).
Requires a to be used for values comparison.
The Room spectators count (Game Rooms only).
Requires a to be used for values comparison.
The Room is a Game Room.
Requires a to be used for values comparison.
The Room is private.
Requires a to be used for values comparison.
The Room has at least one free player slot.
Requires a to be used for values comparison.
The Room is an SFSGame on the server-side.
Requires a to be used for values comparison.
The StringMatch class is used in matching expressions to check string conditions.
An instance of StringMatch representing the following condition: string1 == string2.
An instance of StringMatch representing the following condition: string1 != string2.
An instance of StringMatch representing the following condition: string1.indexOf(string2) != -1.
An instance of StringMatch representing the following condition: string1 starts with characters contained in string2.
An instance of StringMatch representing the following condition: string1 ends with characters contained in string2.
The UserProperties class contains the names of predefined properties that can be used in matching expressions to search/filter users.
The user name.
Requires a to be used for values comparison.
The user is a player in a Game Room.
Requires a to be used for values comparison.
The user is a spectator in a Game Room.
Requires a to be used for values comparison.
The user is a Non-Player Character (NPC).
Requires a to be used for values comparison.
The user privilege id.
Requires a to be used for values comparison.
The user joined at least one Room.
Requires a to be used for values comparison.
The BuddyVariable interface defines all the public methods and properties that an object representing a SmartFoxServer Buddy Variable exposes.
In the SmartFoxServer 2X client API this interface is implemented by the class. Read the class description for additional informations.
Indicates whether the Buddy Variable is persistent or not.
By convention any Buddy Variable whose name starts with the dollar sign ($) will be regarded as persistent and stored locally by the server.
Persistent Buddy Variables are also referred to as "offline variables" because they are available to all users who have the owner in their Buddy Lists, whether that Buddy is online or not.
The IMMOItemVariable interface defines all the public methods and properties that an object representing a SmartFoxServer MMOItem Variable exposes.
In the SmartFoxServer 2X client API this interface is implemented by the class. Read the class description for additional informations.
The MMOItemVariable object represents a SmartFoxServer MMOItem Variable entity on the client.
An MMOItem Variable is a custom value attached to an MMOItem object that gets automatically synchronized between client and server on every change, provided that the MMOItem is inside the Area of Interest of the current user in a MMORoom.
NOTE: MMOItem Variables behave exactly like User Variables and support the same data types, but they can be created, updated and deleted on the server side only.
Returns a string that contains the MMOItem Variable name, type and value.
The string representation of the object.
The ReservedBuddyVariables class contains the costants describing the SmartFoxServer API reserved Buddy Variable names.
Reserved Buddy Variables are used to store specific buddy-related informations.
The Buddy Variable with this name keeps track of the online/offline state of the user in a buddy list.
This variable is persistent, which means that the online/offline state is preserved upon disconnection.
The Buddy Variable with this name stores the custom state of the user in a buddy list.
This variable is persistent, which means that the custom state is preserved upon disconnection.
The Buddy Variable with this name stores the optional nickname of the user in a buddy list.
This variable is persistent, which means that the nickname is preserved upon disconnection.
The ReservedRoomVariables class contains the costants describing the SmartFoxServer API reserved Room Variable names.
The Room Variable with this name keeps track of the state (started or stopped) of a game created with the request.
The RoomVariable interface defines all the public methods and properties that an object representing a SmartFoxServer Room Variable exposes.
In the SmartFoxServer 2X client API this interface is implemented by the class. Read the class description for additional informations.
Indicates whether this Room Variable is private or not.
A private Room Variable is visible to all users in the same Room, but it can be modified by its owner only (the user that created it).
NOTE: setting this property manually on an existing Room Variable returned by the API has no effect on the server and can disrupt the API functioning.
This flag can be set when the Room Variable object is created by the developer only (using the new keyword).
Indicates whether this Room Variable is persistent or not.
A persistent Room Variable continues to exist in the Room after the user who created it has left it and until he disconnects.
NOTE: setting this property manually on an existing Room Variable returned by the API has no effect on the server and can disrupt the API functioning.
This flag can be set when the Room Variable object is created by the developer only (using the new keyword).
The SFSBuddyVariable object represents a SmartFoxServer Buddy Variable entity on the client.
The Buddy Variable is a custom value attached to a Buddy object in a Buddy List that gets automatically synchronized between client and server on every change.
Buddy Variables work with the same principle of the User and Room Variables. The only difference is the logic by which they get propagated to other users.
While Room and User Variables are usually broadcast to all clients in the same Room, Buddy Variables updates are sent to all users who have the owner of the Buddy Variable in their Buddy Lists.
Buddy Variables are particularly useful to store custom user data that must be "visible" to the buddies only, such as a profile, a score, a status message, etc.
Buddy Variables can be set by means of the request; they support the data types listed in the class (also nested). A Buddy Variable can also be null.
There is also a special convention that allows Buddy Variables to be set as "offline". Offline Buddy Variables are persistent values which are made available to all users
who have the owner in their Buddy Lists, whether that Buddy is online or not. In order to make a Buddy Variable persistent, its name should start with a dollar sign ($).
This conventional character is contained in the constant.
The prefix to be added to a Buddy Variable name to make it persistent.
A persistent Buddy Variable is made available to all users who have the owner in their Buddy Lists, whether that Buddy is online or not.
Creates a new SFSBuddyVariable instance.
The name of the Buddy Variable.
The value of the Buddy Variable.
The type of the Buddy Variable among those available in the class. Usually it is not necessary to pass this parameter, as the type is auto-detected from the value.
See .
Returns a string that contains the Buddy Variable name, type and value.
The string representation of the object.
The SFSRoomVariable object represents a SmartFoxServer Room Variable entity on the client.
This is a custom value attached to a Room object that gets automatically synchronized between client and server on every change.
Room Variables are particularly useful to store custom Room data such as a game status and other Room-level informations.
Room Variables can be set by means of the request; they support the data types listed in the class (also nested). A Room Variable can also be null.
Room Variables also support a number of specific flags:
- Private: a private Room Variable can only be modified by its creator.
- Persistent: a persistent Room Variable will continue to exist even if its creator has left the Room (but will be deleted when the creator will get disconnected).
- Global: a global Room Variable will fire update events not only to all users in the Room, but also to all users in the Group to which the Room belongs (NOTE: this flag is not available on the client-side because clients are not allowed to create global Room Variables).
Creates a new SFSRoomVariable instance.
The name of the Room Variable.
The value of the Room Variable.
The type of the Room Variable among those available in the class. Usually it is not necessary to pass this parameter, as the type is auto-detected from the value.
See .
Returns a string that contains the Room Variable name, type, value and isPrivate flag.
The string representation of the object.
The SFSUserVariable object represents a SmartFoxServer User Variable entity on the client.
This is a custom value attached to a User object that gets automatically synchronized between client and server on every change.
User Variables are particularly useful to store custom user data that must be "visible" to the other users, such as a profile, a score, a status message, etc.
User Variables can be set by means of the request; they support the data types listed in the class (also nested). A User Variable can also be null.
User Variables can be 'private' (starting from SFS2X v2.12 with client API v1.7): this flag allows to limit the visibility of variables to their owner only.
In other words User Variables marked as private are not sent to other users, even if located in the same Room.
Creates a new private User Variable.
Private User Variables are not broadcast to other users: they are only visible on the server side and in the owner's client application.
The name of the User Variable.
The value of the User Variable.
Creates a new SFSUserVariable instance.
The name of the User Variable.
The value of the User Variable.
The type of the User Variable among those available in the class. Usually it is not necessary to pass this parameter, as the type is auto-detected from the value.
See .
Returns a string that contains the User Variable name, type, value and IsPrivate flag.
The string representation of the object.
The UserVariable interface defines all the public methods and properties that an object representing a SmartFoxServer User Variable exposes.
In the SmartFoxServer 2X client API this interface is implemented by the class. Read the class description for additional informations.
Indicates whether this User Variable is private or not.
A private User Variable is visible only to its owner; any changes made to the variable will be transmitted to the owner only.
NOTE: setting this property manually on an existing User Variable returned by the API has no effect on the server and can disrupt the API functioning.
This flag can be set when the User Variable object is created by the developer only (using the new keyword).
The VariableType class contains the costants defining the valid types of User and Room Variables to be passed to their constructors.
The User/Room Variable is null.
The type of the User/Room Variable is boolean.
The type of the User/Room Variable is integer.
The type of the User/Room Variable is double.
The type of the User/Room Variable is string.
The type of the User/Room Variable is SFSObject.
The type of the User/Room Variable is SFSArray.
The Variable interface defines all the default public methods and properties that an object representing a SmartFoxServer Variable exposes.
Indicates the name of this variable.
Indicates the type of this variable.
Returns the untyped value of this variable.
Retrieves the value of a boolean variable.
The variable value as a boolean.
Retrieves the value of an integer variable.
The variable value as an integer.
Retrieves the value of a double precision variable.
The variable value as a double.
Retrieves the value of a string variable.
The variable value as a string.
Retrieves the value of a SFSObject variable.
The variable value as an object implementing the interface.
Retrieves the value of a SFSArray variable.
The variable value as an object implementing the interface.
Indicates if the variable is null.
true if the variable has a null value.
The BaseVariable object is the base class for all SmartFoxServer Variable entities on the client.
Creates a new BaseVariable instance.
The name of the Variable.
The value of the Variable.
The type of the Variable among those available in the class. Usually it is not necessary to pass this parameter, as the type is auto-detected from the value.
See .
The LogLevel enumeration contains the costants describing the importance levels of logged messages.
A DEBUG message is a fine-grained information on the client activity.
An INFO message contains informations on the standard client activities.
A WARN message is a warning caused by an unexpected behavior of the client.
Client operations are not compromised when a warning is raised.
An ERROR message contains informations on a problem that occurred during the client activities.
Client operations might be compromised when an error is raised.
The internal logger used by the SmartFoxServer 2X client API.
You can get a reference to the Logger by means of the SmartFox.Logger property.
Accessing the logger can be useful to control the client-side logging level, enable or disable the output towards the console and enable or disable the events dispatching.
When logger events are enabled, you can add your own listners to this class, in order to have a lower access to logged messages (for example you could display them in a dedicated panel in the application interface).
Indicates whether or not the output of logged messages to the console is enabled.
If true, logged messages are displayed using the Console.WriteLine() method for unity or System.Diagnostics.Debug.WriteLine for win8 and win phone.
Indicates whether dispatching of log events is enabled or not.
Determines the current logging level.
Messages with a level lower than this value are not logged. The available log levels are contained in the class.
Registers a delegate method for log messages callbacks.
Calling this method is just like calling the SmartFox.AddLogListener method.
The level of the log events to register a listener for.
The event listener to register.
void SomeMethod() {
sfs.logger.EnableEventDispatching = true;
sfs.Logger.AddEventListener(LogLevel.INFO, OnInfoLogMessage);
sfs.Logger.AddEventListener(LogLevel.WARN, OnWarnLogMessage);
}
void OnInfoLogMessage(BaseEvent evt) {
string message = (string)evt.Params["message"];
Console.WriteLine("[SFS2X INFO] " + message); // .Net / Unity
System.Diagnostics.Debug.WriteLine("[SFS2X INFO] " + message); // Windows Universal
}
void OnWarnLogMessage(BaseEvent evt) {
string message = (string)evt.Params["message"];
Console.WriteLine("[SFS2X WARN] " + message); // .Net / Unity
System.Diagnostics.Debug.WriteLine("[SFS2X WARN] " + message); // Windows Universal
}
Removes a delegate method for log messages callbacks.
Calling this method is just like calling the Sfs2X.SmartFox.RemoveLogListener method.
The level of the log events to remove the listener for.
The event listener to remove.
LoggerEvent is the class representing all the events dispatched by the SmartFoxServer 2X C# API internal logger.
Set this to specify the assembly you want to use when serializing/deserializing the .NET classes
If null (default) - will look for the Type in the current assembly.
Sends an administrator message to a specific user or a group of users.
The current user must have administration privileges to be able to send the message (see the User.PrivilegeId property).
The recipientMode parameter in the class constructor is used to determine the message recipients: a single user or all the users in a Room,
a Group or the entire Zone. Upon message delivery, the clients of the recipient users dispatch the event.
The following example sends an administration message to all the users in the Zone; it also shows how to handle the related event:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.ADMIN_MESSAGE, OnAdminMessage);
// Set the message recipients: all users in the Zone
MessageRecipientMode recipMode = new MessageRecipientMode(MessageRecipientMode.TO_ZONE, null);
// Send the administrator message
sfs.Send( new AdminMessageRequest("Hello to everybody from the Administrator!", recipMode) );
}
void OnAdminMessage(BaseEvent evt) {
Console.WriteLine("The administrator sent the following message: " + (string)evt.Params["message"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("The administrator sent the following message: " + (string)evt.Params["message"]); // Windows Universal
}
Creates a new AdminMessageRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
The message of the administrator to be sent to the target user/s defined by the recipientMode parameter.
An instance of MessageRecipientMode containing the target to which the message should be delivered.
An instance of containing custom parameters to be sent to the recipient user/s (default = null).
See AdminMessageRequest(string, MessageRecipientMode, ISFSObject) constructor.
The BanMode enumeration contains the costants describing the possible banning modalities for a BanUserRequest.
User is banned by IP address.
User is banned by name.
Banishes a user from the server.
The current user must have administration or moderation privileges in order to be able to ban another user (see the User.PrivilegeId property).
The user can be banned by name or by IP address (see the class). Also, the request allows sending a message to the banned user
(to make clear the reason of the following disconnection) which is delivered by means of the event.
Differently from the user being kicked (see the request), a banned user won't be able to connect to the SmartFoxServer instance
until the banishment expires (after 24 hours for client-side banning) or an administrator removes his name/IP address from the list of banned users by means
of the SmartFoxServer 2X Administration Tool.
The following example bans the user Jack from the system:
User userToBan = sfs.UserManager.GetUserByName("Jack");
sfs.Send( new BanUserRequest(userToBan.Id) );
Creates a new BanUserRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
The id of the user to be banned.
A custom message to be delivered to the user before banning him; if null, the default message configured in the SmartFoxServer 2X Administration Tool is used (default = null).
One of the ban modes defined in the class (default = BanMode.BY_NAME).
The number of seconds after which the user is banned after receiving the ban message (default = 5).
The duration of the banishment, expressed in hours (default = 24).
See BanUserRequest(int, string, BanMode, int, int) constructor.
See BanUserRequest(int, string, BanMode, int, int) constructor.
See BanUserRequest(int, string, BanMode, int, int) constructor.
See BanUserRequest(int, string, BanMode, int, int) constructor.
Changes the maximum number of users and/or spectators who can join a Room.
If the operation is successful, the event is dispatched to all the users who subscribed the Group to which the target Room belongs,
including the requester user himself. If the user is not the creator (owner) of the Room, the event is fired.
An administrator or moderator can override this constrain (he is not requested to be the Room's owner).
Please note that some limitations are applied to the passed values (i.e. a client can't set the max users to more than 200, or the max spectators to more than 32).
Alos, if the Room was configured so that resizing is not allowed (see the RoomSettings.Permissions parameter), the request is ignored and no error is fired.
In case the Room's capacity is reduced to a value less than the current number of users/spectators inside the Room, exceeding users are NOT disconnected.
The following example changes the capacity of an existing Room:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.ROOM_CAPACITY_CHANGE, OnRoomCapacityChange);
sfs.AddEventListener(SFSEvent.ROOM_CAPACITY_CHANGE_ERROR, OnRoomCapacityChangeError);
Room theRoom = sfs.GetRoomByName("Gonzo's Room");
// Resize the Room so that it allows a maximum of 100 users and zero spectators
sfs.Send( new ChangeRoomCapacityRequest(theRoom, 100, 0) );
}
void OnRoomCapacityChange(BaseEvent evt) {
Room room = (Room)evt.Params["room"];
Console.WriteLine("The capacity of Room " + room.Name + " was changed successfully"); // .Net / Unity
System.Diagnostics.Debug.WriteLine("The capacity of Room " + room.Name + " was changed successfully"); // Windows Universal
}
void OnRoomCapacityChangeError(BaseEvent evt) {
Console.WriteLine("Room capacity change failed: " + (string)evt.Params["errorMessage"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Room capacity change failed: " + (string)evt.Params["errorMessage"]); // Windows Universal
}
Creates a new ChangeRoomCapacityRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
The object corresponding to the Room whose capacity should be changed.
The new maximum number of users/players who can join the Room.
The new maximum number of spectators who can join the Room (for Game Rooms only).
Changes the name of a Room.
If the renaming operation is successful, the event is dispatched to all the users who subscribed the Group to which the target Room belongs,
including the user who renamed it. If the user is not the creator (owner) of the Room, or if the new name doesn't match the related criteria in Zone configuration, the
event is fired. An administrator or moderator can override this constrain (he is not requested to be the Room's owner).
If the Room was configured so that renaming is not allowed (see the RoomSettings.Permissions parameter), the request is ignored and no error is fired.
The following example renames an existing Room:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.ROOM_NAME_CHANGE, OnRoomNameChange);
sfs.AddEventListener(SFSEvent.ROOM_NAME_CHANGE_ERROR, OnRoomNameChangeError);
Room theRoom = sfs.GetRoomByName("Gonzo's Room");
sfs.Send( new ChangeRoomNameRequest(theRoom, "Gonzo The Great's Room") );
}
void OnRoomNameChange(BaseEvent evt) {
Room theRoom = (Room)evt.Params["room"];
Console.WriteLine("Room " + (string)evt.Params["oldName"] + " was successfully renamed to " + theRoom.Name); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Room " + (string)evt.Params["oldName"] + " was successfully renamed to " + theRoom.Name); // Windows Universal
}
void OnRoomNameChangeError(BaseEvent evt) {
Console.WriteLine("Room name change failed: " + (string)evt.Params["errorMessage"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Room name change failed: " + (string)evt.Params["errorMessage"]); // Windows Universal
}
Creates a new ChangeRoomNameRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
The object corresponding to the Room whose name should be changed.
The new name to be assigned to the Room.
Changes the password of a Room.
This request not only changes the password of a Room, but also its "password state", which indicates if the Room is password protected or not.
If the operation is successful, the event is dispatched to all the users who subscribed the Group
to which the target Room belongs, including the requester user himself. If the user is not the creator (owner) of the Room, the event is fired.
An administrator or moderator can override this constrain (he is not requested to be the Room's owner).
If the Room was configured so that password change is not allowed (see the RoomSettings.Permissions parameter), the request is ignored and no error is fired.
The following example changes the password of an existing Room:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.ROOM_PASSWORD_STATE_CHANGE, OnRoomPasswordStateChange);
sfs.AddEventListener(SFSEvent.ROOM_PASSWORD_STATE_CHANGE_ERROR, OnRoomPasswordStateChangeError);
Room theRoom = sfs.GetRoomByName("Gonzo's Room");
sfs.Send( new ChangeRoomPasswordStateRequest(theRoom, "mammamia") );
}
void OnRoomPasswordStateChange(BaseEvent evt) {
Room theRoom = (Room)evt.Params["room"];
Console.WriteLine("The password of Room " + theRoom.Name + " was changed successfully"); // .Net / Unity
System.Diagnostics.Debug.WriteLine("The password of Room " + theRoom.Name + " was changed successfully"); // Windows Universal
}
void OnRoomPasswordStateChangeError(BaseEvent evt) {
Console.WriteLine("Room password change failed: " + (string)evt.Params["errorMessage"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Room password change failed: " + (string)evt.Params["errorMessage"]); // Windows Universal
}
Creates a new ChangeRoomPasswordStateRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
The object corresponding to the Room whose password should be changed.
The new password to be assigned to the Room; an empty string or a null value can be passed to remove the Room's password.
Creates a new Room in the current Zone.
If the creation is successful, a event is dispatched to all the users who subscribed the Group to which the Room is associated,
including the Room creator. Otherwise, a event is returned to the creator's client.
The following example creates a new chat room:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.ROOM_ADDED, OnRoomAdded);
sfs.AddEventListener(SFSEvent.ROOM_CREATION_ERROR, OnRoomCreationError);
// Create a new Chat Room
RoomSettings settings = new RoomSettings("My Chat Room");
settings.MaxUsers = 40;
settings.GroupId = "chats";
sfs.Send( new CreateRoomRequest(settings) );
}
void OnRoomAdded(BaseEvent evt) {
Console.WriteLine("Room created: " + (Room)evt.Params["room"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Room created: " + (Room)evt.Params["room"]); // Windows Universal
}
void OnRoomCreationError(BaseEvent evt) {
Console.WriteLine("Room creation failed: " + (string)evt.Params["errorMessage"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Room creation failed: " + (string)evt.Params["errorMessage"]); // Windows Universal
}
Creates a new CreateRoomRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
An object containing the Room configuration settings.
If true, the Room is joined as soon as it is created (default = false).
An object representing the Room that should be left if the new Room is auto-joined (default = null).
See CreateRoomRequest(RoomSettings, bool, Room) constructor.
See CreateRoomRequest(RoomSettings, bool, Room) constructor.
Sends a command to the server-side Extension attached to the Zone or to a Room.
This request is used to send custom commands from the client to a server-side Extension, be it a Zone-level or Room-level Extension.
Viceversa, the event is used by the server to send Extension commands/responses to the client.
Read the SmartFoxServer 2X documentation about server-side Extension for more informations.
The ExtensionRequest request can be sent using the UDP protocol too: this allows sending fast stream of packets to the server in real-time type games,
typically for position/transformation updates, etc.
The following example sends a command to the Zone Extension; it also handles responses coming from the Extension by implementing the event listener (the same command name is used in both the request and the response):
void SomeMethod() {
sfs.addEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);
// Send two integers to the Zone extension and get their sum in return
ISFSObject params = SFSObject.NewInstance();
params.PutInt("n1", 26);
params.PutInt("n2", 16);
sfs.Send( new ExtensionRequest("add", params) );
}
void OnExtensionResponse(BaseEvent evt) {
String cmd = (String)evt.Params["cmd"];
if (cmd == "add") {
ISFSObject responseParams = (SFSObject)evt.Params["params"];
// We expect an int parameter called "sum"
Console.WriteLine("The sum is: " + responseParams.GetInt("sum")); // .Net / Unity
System.Diagnostics.Debug.WriteLine("The sum is: " + responseParams.GetInt("sum")); // Windows Universal
}
}
Creates a new ExtensionRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
The name of the command which identifies an action that should be executed by the server-side Extension.
An instance of containing custom data to be sent to the Extension (default = null). Can be null if no data needs to be sent.
If null, the specified command is sent to the current Zone server-side Extension; if not null, the command is sent to the server-side Extension attached to the passed Room (default = null).
If true, the UDP protocol is used to send the request to the server (default = false).
See ExtensionRequest(string, ISFSObject, Room, bool) constructor.
See ExtensionRequest(string, ISFSObject, Room, bool) constructor.
Retrieves a list of Rooms from the server which match the specified criteria.
By providing a matching expression and a search scope (a Group or the entire Zone), SmartFoxServer can find those Rooms matching the passed criteria
and return them by means of the event.
The following example looks for all the server Rooms whose "country" Room Variable is set to Sweden:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.ROOM_FIND_RESULT, OnRoomFindResult);
// Create a matching expression to find Rooms with a "country" variable equal to "Sweden"
MatchExpression expr = new MatchExpression('country', StringMatch.EQUALS, 'Sweden');
// Find the Rooms
sfs.Send( new FindRoomRequest(expr) );
}
void OnRoomFindResult(BaseEvent evt) {
Console.WriteLine("Rooms found: " + (List<Room>)evt.Params["rooms"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Rooms found: " + (List<Room>)evt.Params["rooms"]); // Windows Universal
}
Creates a new FindRoomsRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
A matching expression that the system will use to retrieve the Rooms.
The name of the Group where to search for matching Rooms; if null, the search is performed in the whole Zone (default = null).
The maximum size of the list of Rooms that will be returned by the roomFindResult event. If 0, all the found Rooms are returned (default = 0).
See FindRoomsRequest(MatchExpression, string, int) constructor.
See FindRoomsRequest(MatchExpression, string, int) constructor.
Retrieves a list of users from the server which match the specified criteria.
By providing a matching expression and a search scope (a Room, a Group or the entire Zone), SmartFoxServer can find
those users matching the passed criteria and return them by means of the event.
The following example looks for all the users whose "age" User Variable is greater than 29:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.USER_FIND_RESULT, OnUserFindResult);
// Create a matching expression to find users with an "age" variable greater than 29:
MatchExpression expr = new MatchExpression("age", NumberMatch.GREATER_THAN, 29);
// Find the users
sfs.Send( new FindUsersRequest(expr) );
}
void OnUserFindResult(BaseEvent evt) {
Console.WriteLine("Users found: " + (List<User>)evt.Params["users"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Users found: " + (List<User>)evt.Params["users"]); // Windows Universal
}
Creates a new FindUsersRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
A matching expression that the system will use to retrieve the users.
The name of a Group or a single Room object where to search for matching users; if null, the search is performed in the whole Zone (default = null).
The maximum size of the list of users that will be returned by the userFindResult event. If 0, all the found users are returned (default = 0).
See FindUsersRequest(MatchExpression, string, int) constructor.
See FindUsersRequest(MatchExpression, string, int) constructor.
See FindUsersRequest(MatchExpression, string, int) constructor.
See FindUsersRequest(MatchExpression, string, int) constructor.
This request is used by the API sub-system at connection time. It's not intended for other uses.
Joins the current user in a Room.
If the operation is successful, the current user receives a event; otherwise the event is fired.
This usually happens when the Room is full, or the password is wrong in case of password protected Rooms.
Depending on the Room configuration defined upon its creation (see the RoomSettings.Events setting), when the current user joins it,
the following events might be fired: , dispatched to the other users inside the Room to warn them that a new user has arrived;
, dispatched to all clients which subscribed the Group to which the Room belongs, to update the count of users inside the Room.
The following example makes the user join an existing Room:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnJoinRoom);
sfs.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnJoinRoomError);
// Join a Room called "Lobby"
sfs.Send( new JoinRoomRequest("Lobby") );
}
void OnJoinRoom(BaseEvent evt) {
Console.WriteLine("Room joined successfully: " + (Room)evt.Params["room"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Room joined successfully: " + (Room)evt.Params["room"]); // Windows Universal
}
void OnJoinRoomError(BaseEvent evt) {
Console.WriteLine("Room joining failed: " + (string)evt.Params["errorMessage"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Room joining failed: " + (string)evt.Params["errorMessage"]); // Windows Universal
}
Creates a new JoinRoomRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
The id or the name of the Room to be joined.
The password of the Room, in case it is password protected (default = null).
The id of a previously joined Room that the user should leave when joining the new Room. By default, the last joined Room is left; if a negative number is passed, no previous Room is left (default = null).
true to join the Room as a spectator (in Game Rooms only) (default = false).
See JoinRoomRequest(object, string, int?, bool) constructor.
See JoinRoomRequest(object, string, int?, bool) constructor.
See JoinRoomRequest(object, string, int?, bool) constructor.
Kicks a user out of the server.
The current user must have administration or moderation privileges in order to be able to kick another user (see the User.PrivilegeId property).
The request allows sending a message to the kicked user (to make clear the reason of the following disconnection) which is delivered by means of the event.
Differently from the user being banned (see the request), a kicked user will be able to reconnect to the SmartFoxServer instance immediately.
The following example kicks the user Jack from the system:
User userToKick = sfs.UserManager.GetUserByName("Jack");
sfs.Send( new KickUserRequest(userToKick.Id) );
Creates a new KickUserRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
The id of the user to be kicked.
A custom message to be delivered to the user before kicking him; if null, the default message configured in the SmartFoxServer 2X Administration Tool is used (default = null).
The number of seconds after which the user is kicked after receiving the kick message (default = 5).
See KickUserRequest(int, string, int) constructor.
See KickUserRequest(int, string, int) constructor.
Leaves one of the Rooms joined by the current user.
Depending on the Room configuration defined upon its creation (see the RoomSettings.Events setting), when the current user leaves it,
the following events might be fired: , dispatched to all the users inside the Room (including the current user then)
to warn them that a user has gone away; , dispatched to all clients which subscribed the Group to which the Room belongs,
to update the count of users inside the Room.
The following example makes the user leave the currently joined Room and handles the respective event:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.USER_EXIT_ROOM, OnUserExitRoom);
// Leave the last joined Room
sfs.Send( new LeaveRoomRequest() );
}
void OnUserExitRoom(BaseEvent evt) {
User user = (User)evt.Params["user"];
Room room = (Room)evt.Params["room"];
Console.WriteLine(""User " + user.Name + " just left Room " + room.Name); // .Net / Unity
System.Diagnostics.Debug.WriteLine(""User " + user.Name + " just left Room " + room.Name); // Windows Universal
}
Creates a new LeaveRoomRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
The Room object corresponding to the Room that the current user must leave. If null, the last Room joined by the user is left (default = null).
See LeaveRoomRequest(Room) constructor.
Logs the current user in one of the server Zones.
Each Zone represent an indipendent multiuser application governed by SmartFoxServer. In order to join a Zone, a user name and password are usually required.
In order to validate the user credentials, a custom login process should be implemented in the Zone's server-side Extension.
Read the SmartFoxServer 2X documentation about the login process for more informations.
If the login operation is successful, the current user receives a event; otherwise the event is fired.
The following example performs a login in the "SimpleChat" Zone:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
// Login
sfs.Send( new LoginRequest("FozzieTheBear", "", "SimpleChat") );
}
void OnLogin(BaseEvent evt) {
Console.WriteLine("Login successful!"); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Login successful!"); // Windows Universal
}
void OnLoginError(BaseEvent evt) {
Console.WriteLine("Login failure: " + (string)evt.Params["errorMessage"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Login failure: " + (string)evt.Params["errorMessage"]); // Windows Universal
}
Creates a new LoginRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
The name to be assigned to the user. If an empty string is passed and the Zone allows guest users, the name is generated automatically by the server.
The user password to access the system. SmartFoxServer doesn't offer a default authentication system, so the password must be validated implementing a custom login system in the Zone's server-side Extension.
The name (case-sensitive) of the server Zone to login to; if a Zone name is not specified, the client will use the setting loaded via method.
An instance of containing custom parameters to be passed to the Zone Extension (requires a custom login system to be in place). Default value is null.
See LoginRequest(string, string, string, ISFSObject) constructor.
See LoginRequest(string, string, string, ISFSObject) constructor.
See LoginRequest(string, string, string, ISFSObject) constructor.
Logs the user out of the current server Zone.
The user is notified of the logout operation by means of the event. This doesn't shut down the connection,
so the user will be able to login again in the same Zone or in a different one right after the confirmation event.
The following example performs a logout from the current Zone:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.LOGOUT, onLogout);
// Logout
sfs.Send( new LogoutRequest() );
}
void onLogout(BaseEvent evt) {
Console.WriteLine("Logout executed!"); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Logout executed!"); // Windows Universal
}
Creates a new LogoutRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
This is used by the system. Never send this directly.
The possible message recipient modes for ModeratorMessageRequest and AdminMessageRequest requests.
The moderator/administrator message will be sent to a specific user.
A User instance must be passed as target parameter to the class constructor.
The moderator/administrator message will be sent to all the users in a specific Room.
A Room instance must be passed as target parameter to the class constructor.
The moderator/administrator message will be sent to all the clients who subscribed a specific Room Group.
A Group id must be passed as target parameter to the class constructor.
The moderator/administrator message will be sent to all the users in the Zone.
null can be passed as target parameter to the class, in fact it will be ignored.
The MessageRecipientMode class is used to specify the recipient/s of moderator and administrator messages.
Read the constants descriptions in the enumeration for more informations.
Returns the moderator/administrator message target, according to the selected recipient mode.
Returns the selected recipient mode.
Creates a new MessageRecipientMode instance.
The instance must be passed as recipientMode parameter to the and classes constructors.
One of the costants contained in the enumerator, describing the recipient mode.
The moderator/administrator message recipient/s, according to the selected recipient mode.
Sends a moderator message to a specific user or a group of users.
The current user must have moderation privileges to be able to send the message (see the User.PrivilegeId property).
The recipientMode parameter in the class constructor is used to determine the message recipients: a single user or all the users in a Room,
a Group or the entire Zone. Upon message delivery, the clients of the recipient users dispatch the event.
The following example sends a moderator message to all the users in the last joned Room; it also shows how to handle the related event:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.MODERATOR_MESSAGE, OnModeratorMessage);
// Set the message recipients: all users in the current Room
MessageRecipientMode recipMode = new MessageRecipientMode(MessageRecipientMode.TO_ROOM, sfs.LastJoinedRoom);
// Send the moderator message
sfs.Send( new ModeratorMessageRequest("Hello everybody, I'm the Moderator!", recipMode) );
}
void OnModeratorMessage(BaseEvent evt) {
Console.WriteLine("The moderator sent the following message: " + (string)evt.Params["message"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("The moderator sent the following message: " + (string)evt.Params["message"]); // Windows Universal
}
Creates a new ModeratorMessageRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
The message of the moderator to be sent to the target user/s defined by the recipientMode parameter.
An instance of MessageRecipientMode containing the target to which the message should be delivered.
An instance of containing custom parameters to be sent to the recipient user/s (default = null).
See ModeratorMessageRequest(string, MessageRecipientMode, ISFSObject) constructor.
Sends an object containing custom data to all users in a Room, or a subset of them.
The data object is delivered to the selected users (or all users excluding the sender) inside the target Room by means of the event.
It can be useful to send game data, like for example the target coordinates of the user's avatar in a virtual world.
The following example sends the player's character movement coordinates and handles the respective event:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.OBJECT_MESSAGE, OnObjectMessage);
// Send a game move to all players
ISFSObject dataObj = new SFSObject();
dataObj.PutInt("x", myAvatar.x);
dataObj.PutInt("y", myAvatar.y);
sfs.Send( new ObjectMessageRequest(dataObj) );
}
void OnObjectMessage(BaseEvent evt) {
ISFSObject dataObj = (SFSObject)evt.Params["message"];
int x = dataObj.GetInt("x");
int y = dataObj.GetInt("y");
// etc...
}
Creates a new ObjectMessageRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
An instance of containing custom parameters to be sent to the message recipients.
The Room object corresponding to the Room where the message should be dispatched; if null, the last Room joined by the user is used (default = null).
A collection of User objects corresponding to the message recipients (default = null); if null, the message is sent to all users in the target Room (except the sender himself).
See ObjectMessageRequest(ISFSObject, Room, ICollection<User>) constructor.
See ObjectMessageRequest(ISFSObject, Room, ICollection<User>) constructor.
Sends a ping-pong request in order to measure the current lag
Turns the current user from player to spectator in a Game Room.
If the operation is successful, all the users in the target Room are notified with the event.
The operation could fail if no spectator slots are available in the Game Room at the time of the request;
in this case the event is dispatched to the requester's client.
The following example turns the current user from player to spectator in the last joined Game Room:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.PLAYER_TO_SPECTATOR, OnPlayerToSpectatorSwitch);
sfs.AddEventListener(SFSEvent.PLAYER_TO_SPECTATOR_ERROR, OnPlayerToSpectatorSwitchError);
// Switch player to spectator
sfs.Send( new PlayerToSpectatorRequest() );
}
void OnPlayerToSpectatorSwitch(BaseEvent evt) {
User user = (User)evt.Params["user"];
Console.WriteLine("Player " + user.Name + " is now a spectator"); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Player " + user.Name + " is now a spectator"); // Windows Universal
}
void OnPlayerToSpectatorSwitchError(BaseEvent evt) {
Console.WriteLine("Unable to become a spectator due to the following error: " + (string)evt.Params["errorMessage"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Unable to become a spectator due to the following error: " + (string)evt.Params["errorMessage"]); // Windows Universal
}
Creates a new PlayerToSpectatorRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
The object corresponding to the Room in which the player should be turned to spectator. If null, the last Room joined by the user is used (default = null).
See PlayerToSpectatorRequest(Room) constructor.
Sends a private chat message.
The private message is dispatched to a specific user, who can be in any server Room, or even in no Room at all. The message is delivered by means of the event.
It is also returned to the sender: this allows showing the messages in the correct order in the application interface. It is also possible to send an optional object together with the message:
it can contain custom parameters useful to transmit, for example, additional informations related to the message, like the text font or color, or other formatting details.
The following example sends a private message and handles the respective event:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.PRIVATE_MESSAGE, OnPrivateMessage);
// Send a private message to Jack
User messageRecipient = sfs.UserManager.GetUserByName("Jack");
sfs.Send( new PrivateMessageRequest("Hello Jack!", messageRecipient.Id) );
}
void OnPrivateMessage(BaseEvent evt) {
// As messages are forwarded to the sender too, I have to check if I am the sender
User sender = (User)evt.Params["sender"];
if (sender != sfs.MySelf)
{
Console.WriteLine("User " + sender.Name + " sent me this PM: " + (string)evt.Params["message"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("User " + sender.Name + " sent me this PM: " + (string)evt.Params["message"]); // Windows Universal
}
}
Creates a new PrivateMessageRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
The message to be sent to to the recipient user.
The id of the user to which the message is to be sent.
An instance of containing additional custom parameters to be sent to the message recipient (for example the color of the text, etc). Default value is null.
See PrivateMessageRequest(string, int, ISFSObject) constructor.
Sends a public chat message.
A public message is dispatched to all the users in the specified Room, including the message sender (this allows showing messages in the correct order in the application interface);
the corresponding event is the event. It is also possible to send an optional object together with the message: it can contain
custom parameters useful to transmit, for example, additional informations related to the message, like the text font or color, or other formatting details.
In case the target Room is not specified, the message is sent in the last Room joined by the sender.
NOTE: the event is dispatched if the Room is configured
to allow public messaging only (see the RoomSettings.Permissions parameter).
The following example sends a public message and handles the respective event:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage);
// Send a public message
sfs.Send( new PublicMessageRequest("Hello everyone!") );
}
void OnPublicMessage(BaseEvent evt) {
// As messages are forwarded to the sender too, I have to check if I am the sender
User sender = (User)evt.Params["sender"];
if (sender == sfs.MySelf)
{
Console.WriteLine("I said " + (string)evt.Params["message"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("I said " + (string)evt.Params["message"]); // Windows Universal
}
else
{
Console.WriteLine("User " + sender.Name + " said: " + (string)evt.Params["message"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("User " + sender.Name + " said: " + (string)evt.Params["message"]); // Windows Universal
}
}
Creates a new PublicMessageRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
The message to be sent to all the users in the target Room.
An instance of containing additional custom parameters to be sent to the message recipients (for example the color of the text, etc). Default value is null.
The object corresponding to the Room where the message should be dispatched; if null, the last Room joined by the user is used (default = null).
See PublicMessageRequest(string, ISFSObject, Room) constructor.
See PublicMessageRequest(string, ISFSObject, Room) constructor.
The RoomEvents class contains a specific subset of the RoomSettings required to create a Room.
This class defines which events related to the Room will be fired by the SmartFox client.
Creates a new RoomEvents instance.
The RoomSettings.Events property must be set to this instance during Room creation.
Indicates whether the event should be dispatched whenever a user joins the Room or not.
The default value is false.
Indicates whether the event should be dispatched whenever a user leaves the Room or not.
The default value is false.
Indicates whether or not the event should be dispatched whenever the users (or players+spectators) count changes in the Room.
The default value is false.
Indicates whether or not the event should be dispatched whenever a user in the Room updates his User Variables.
The default value is false.
The RoomExtension class contains a specific subset of the RoomSettings required to create a Room.
This class defines which server-side Extension should be attached to the Room upon creation.
The client can communicate with the Room Extension by means of the request.
Creates a new RoomExtension instance.
The RoomSettings.Extension property must be set to this instance during Room creation.
The name of the Extension as deployed on the server; it's the name of the folder containing the Extension classes inside the main [sfs2x-install-folder]/SFS2X/extensions folder.
The fully qualified name of the main class of the Extension.
Returns the name of the Extension to be attached to the Room.
This is the name of the server-side folder containing the Extension classes inside the main [sfs2x-install-folder]/SFS2X/extensions folder.
Returns the fully qualified name of the main class of the Extension.
Defines the name of an optional properties file that should be loaded on the server-side during the Extension initialization.
The file must be located in the server-side folder containing the Extension classes.
The RoomPermissions class contains a specific subset of the RoomSettings required to create a Room.
This class defines which operations users will be able to execute on the Room after its creation.
Creates a new RoomPermissions instance.
The RoomSettings.Permissions property must be set to this instance during Room creation.
Indicates whether changing the Room name after its creation is allowed or not.
The Room name can be changed by means of the request.
The default value is false.
Indicates whether changing (or removing) the Room password after its creation is allowed or not.
The Room password can be changed by means of the request.
The default value is false.
Indicates whether users inside the Room are allowed to send public messages or not.
Public messages can be sent by means of the request.
The default value is false.
Indicates whether the Room capacity can be changed after its creation or not.
The capacity is the maximum number of users and spectators (in Game Rooms) allowed to enter the Room. It can be changed by means of the request.
The default value is false.
The RoomSettings class is a container for the settings required to create a Room.
Creates a new RoomSettings instance.
The instance must be passed to the class constructor.
The name of the Room to be created.
Defines the name of the Room.
Defines the password of the Room.
If the password is set to an empty string, the Room won't be password protected.
The default value is an empty string.
Indicates whether the Room is a Game Room or not.
The default value is false.
Defines the maximum number of users allowed in the Room.
In case of Game Rooms, this is the maximum number of players.
The default value is 10.
Defines the maximum number of Room Variables allowed for the Room.
The default value is 5.
Defines the maximum number of spectators allowed in the Room (only for Game Rooms).
The default value is 0.
Defines a list of RooomVariable objects to be attached to the Room.
The default value is null.
Defines the flags indicating which operations are permitted on the Room.
Permissions include: name and password change, maximum users change and public messaging. If set to null,
the permissions configured on the server-side are used (see the SmartFoxServer 2X Administration Tool documentation).
The default value is null.
Defines the flags indicating which events related to the Room are dispatched by the SmartFox client.
Room events include: users entering or leaving the room, user count change and user variables update. If set to null,
the events configured on the server-side are used (see the SmartFoxServer 2X Administration Tool documentation).
The default value is null.
Defines the Extension that must be attached to the Room on the server-side, and its settings.
Defines the id of the Group to which the Room should belong.
If the Group doesn't exist yet, a new one is created before assigning the Room to it.
The default value is default.
Specifies if the Room allows "Join Room" invitations to be sent by any user or just by its owner.
The default value is true.
Sets one or more custom Room Variables in a Room.
When a Room Variable is set, the event is dispatched to all the users in the target Room, including the user who updated it.
Also, if the Room Variable is global (see the class description), the event is dispatched to all users who subscribed the Group to which the target Room is associated.
The following example sets a number of Room Variables and handles the respective update event:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.ROOM_VARIABLES_UPDATE, OnRoomVarsUpdate);
// Create some Room Variables
List<RoomVariable> roomVars = new List<RoomVariable>();
roomVars.Add( new SFSRoomVariable("gameStarted", false) );
roomVars.Add( new SFSRoomVariable("gameType", "Snooker") );
roomVars.Add( new SFSRoomVariable("minRank", 10) );
sfs.Send( new SetRoomVariablesRequest(roomVars) );
}
void OnRoomVarsUpdate(BaseEvent evt) {
List<String> changedVars = (List<String>)evt.Params["changedVars"];
Room room = (Room)evt.Params["room"];
// Check if the gameStarted variable was changed
if (changedVars.Contains ("gameStarted")) {
if (room.GetVariable("gameStarted").GetBoolValue()) {
Console.WriteLine("Game started"); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Game started"); // Windows Universal
} else {
Console.WriteLine("Game stopped"); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Game stopped"); // Windows Universal
}
}
}
Creates a new SetRoomVariablesRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
A collection of objects representing the Room Variables to be set.
An object representing the Room where to set the Room Variables; if null, the last Room joined by the current user is used (default = null).
See SetRoomVariablesRequest(ICollection<RoomVariable>, Room) constructor.
Sets one or more custom User Variables for the current user.
When a User Variable is set, the event is dispatched to all the users in all the Rooms joined by the current user, including himself.
NOTE: the event is dispatched to users in a specific Room
only if it is configured to allow this event (see the RoomSettings.Permissions parameter).
The following example sets a number of User Variables and handles the respective update event:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.USER_VARIABLES_UPDATE, OnUserVarsUpdate);
// Create some User Variables
List<UserVariable> userVars = new List<UserVariable>();
userVars.Add( new SFSUserVariable("avatarType", "SwedishCook") );
userVars.Add( new SFSUserVariable("country", "Sweden") );
userVars.Add( new SFSUserVariable("x", 10) );
userVars.Add( new SFSUserVariable("y", 5) );
sfs.Send( new SetUserVariablesRequest(userVars) );
}
void OnUserVarsUpdate(BaseEvent evt) {
List<String> changedVars = (List<String>)evt.Params["changedVars"];
User user = (User)evt.Params["user"];
// Check if the user changed his x and y User Variables
if (changedVars.Contains("x") || changedVars.Contains("y"))
{
// Move the character to a new position...
UpdateClientPosition(user);
}
}
Creates a new SetUserVariablesRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
A collection of objects representing the User Variables to be set.
Turns the current user from spectator to player in a Game Room.
If the operation is successful, all the users in the target Room are notified with the event.
The operation could fail if no player slots are available in the Game Room at the time of the request;
in this case the event is dispatched to the requester's client.
The following example turns the current user from spectator to player in the last joined Game Room:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.SPECTATOR_TO_PLAYER, OnSpectatorToPlayerSwitch);
sfs.AddEventListener(SFSEvent.SPECTATOR_TO_PLAYER_ERROR, OnSpectatorToPlayerSwitchError);
// Switch spectator to player
sfs.Send( new PlayerToSpectatorRequest() );
}
void OnSpectatorToPlayerSwitch(BaseEvent evt) {
User user = (User)evt.Params["user"];
Console.WriteLine("Spectator " + user.Name + " is now a player"); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Spectator " + user.Name + " is now a player"); // Windows Universal
}
void OnSpectatorToPlayerSwitchError(BaseEvent evt) {
Console.WriteLine("Unable to become a player due to the following error: " + (string)evt.Params["errorMessage"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Unable to become a player due to the following error: " + (string)evt.Params["errorMessage"]); // Windows Universal
}
Creates a new SpectatorToPlayerRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
The object corresponding to the Room in which the spectator should be turned to player. If null, the last Room joined by the user is used (default = null).
See SpectatorToPlayerRequest(Room) constructor.
Subscribes the current user to Room-related events occurring in the specified Group.
This allows the user to be notified of specific Room events even if he didn't join the Room from which the events originated, provided the Room belongs to the subscribed Group.
If the subscription operation is successful, the current user receives a event; otherwise the event is fired.
The following example makes the current user subscribe a Group:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.ROOM_GROUP_SUBSCRIBE, OnSubscribeRoomGroup);
sfs.AddEventListener(SFSEvent.ROOM_GROUP_SUBSCRIBE_ERROR, OnSubscribeRoomGroupError);
// Subscribe the "card_games" group
sfs.Send( new SubscribeRoomGroupRequest("card_games") );
}
void OnSubscribeRoomGroup(BaseEvent evt) {
Console.WriteLine("Group subscribed. The following rooms are now accessible: " + (List<Room>)evt.Params["newRooms"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Group subscribed. The following rooms are now accessible: " + (List<Room>)evt.Params["newRooms"]); // Windows Universal
}
void OnSubscribeRoomGroupError(BaseEvent evt) {
Console.WriteLine("Group subscription failed: " + (string)evt.Params["errorMessage"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Group subscription failed: " + (string)evt.Params["errorMessage"]); // Windows Universal
}
Creates a new SubscribeRoomGroupRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
The name of the Room Group to subscribe.
Unsubscribes the current user to Room-related events occurring in the specified Group.
This allows the user to stop being notified of specific Room events occurring in Rooms belonging to the unsubscribed Group.
If the operation is successful, the current user receives a event; otherwise the event is fired.
The following example makes the current user unsubscribe a Group:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.ROOM_GROUP_UNSUBSCRIBE, OnUnsubscribeRoomGroup);
sfs.AddEventListener(SFSEvent.ROOM_GROUP_UNSUBSCRIBE_ERROR, OnUnsubscribeRoomGroupError);
// Unsubscribe the "card_games" group
sfs.Send( new UnsubscribeRoomGroupRequest("card_games") );
}
void OnUnsubscribeRoomGroup(BaseEvent evt) {
Console.WriteLine("Group unsubscribed: " + (string)evt.Params["groupId"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Group unsubscribed: " + (string)evt.Params["groupId"]); // Windows Universal
}
void OnUnsubscribeRoomGroupError(BaseEvent evt) {
Console.WriteLine("Group unsubscribing failed: " + (string)evt.Params["errorMessage"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Group unsubscribing failed: " + (string)evt.Params["errorMessage"]); // Windows Universal
}
Creates a new UnsubscribeRoomGroupRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
The name of the Room Group to unsubscribe.
Adds a new buddy to the current user's buddies list.
In order to add a buddy, the current user must be online in the Buddy List system.
If the buddy is added successfully, the operation is confirmed by a event;
otherwise the event is fired.
This request can be sent if the Buddy List system was previously initialized only (see the request description).
The following example sends a request to add a buddy:
void SomeMethod() {
sfs.AddEventListener(SFSBuddyEvent.BUDDY_ADD, OnBuddyAdded);
sfs.AddEventListener(SFSBuddyEvent.BUDDY_ERROR, OnBuddyError);
// Add Jack as a new buddy to my buddies list
sfs.Send(new AddBuddyRequest("Jack"));
}
void OnBuddyAdded(BaseEvent evt) {
Console.WriteLine("Buddy was added: " + (Buddy)evt.Params["buddy"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Buddy was added: " + (Buddy)evt.Params["buddy"]); // Windows Universal
}
void OnBuddyError(BaseEvent evt) {
Console.WriteLine("The following error occurred while executing a buddy-related request: " + (string)evt.Params["errorMessage"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("The following error occurred while executing a buddy-related request: " + (string)evt.Params["errorMessage"]); // Windows Universal
}
Creates a new AddBuddyRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
The name of the user to be added as a buddy.
Blocks or unblocks a buddy in the current user's buddies list. Blocked buddies won't be able to send messages or requests to that user.
In order to block a buddy, the current user must be online in the Buddy List system.
If the operation is successful, a confirmation event is dispatched; otherwise the event is fired.
This request can be sent if the Buddy List system was previously initialized only (see the request description).
The following example sends a request to block a buddy:
void SomeMethod() {
sfs.AddEventListener(SFSBuddyEvent.BUDDY_BLOCK, onBuddyBlock);
sfs.AddEventListener(SFSBuddyEvent.BUDDY_ERROR, OnBuddyError);
// Block Jack in my buddies list
sfs.Send(new BlockBuddyRequest("Jack", true));
}
void onBuddyBlock(BaseEvent evt) {
Buddy buddy = (Buddy)evt.Params["buddy"];
Console.WriteLine("Buddy " + buddy.Name + " is now " + (buddy.IsBlocked ? "blocked" : "unblocked")); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Buddy " + buddy.Name + " is now " + (buddy.IsBlocked ? "blocked" : "unblocked")); // Windows Universal
}
void OnBuddyError(BaseEvent evt) {
Console.WriteLine("The following error occurred while executing a buddy-related request: " + (string)evt.Params["errorMessage"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("The following error occurred while executing a buddy-related request: " + (string)evt.Params["errorMessage"]); // Windows Universal
}
Creates a new BlockBuddyRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
The name of the buddy to be blocked or unblocked.
true if the buddy must be blocked; false if he must be unblocked.
Sends a message to a buddy in the current user's buddies list.
Messages sent to buddies using the request are similar to the standard private messages (see the request)
but are specifically designed for the Buddy List system: they don't require any Room parameter, nor they require that users joined a Room.
Additionally, buddy messages are subject to specific validation, such as making sure that the recipient is in the sender's buddies list and the sender is not blocked by the recipient.
If the operation is successful, a event is dispatched in both the sender and recipient clients.
This request can be sent if the Buddy List system was previously initialized only (see the request description).
The following example sends a message to a buddy and handles the related event:
void SomeMethod() {
sfs.AddEventListener(SFSBuddyEvent.BUDDY_MESSAGE, OnBuddyMessage);
// Obtain the recipient of the message
Buddy kermitTheFrog = sfs.BuddyListManager.GetBuddyByName("KermitTheFrog");
// Block a buddy in the current buddy list
sfs.Send(new BuddyMessageRequest("Hello Kermit!", kermitTheFrog));
}
void OnBuddyMessage(BaseEvent evt) {
bool isItMe = (bool)evt.Params["isItMe"];
Buddy buddy = (Buddy)evt.Params["buddy"];
if (isItMe)
{
Console.WriteLine("I said: " + (string)evt.Params["message"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("I said: " + (string)evt.Params["message"]); // Windows Universal
}
else
{
Console.WriteLine(buddy.Name + " said: " + (string)evt.Params["message"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine(buddy.Name + " said: " + (string)evt.Params["message"]); // Windows Universal
}
}
Creates a new BuddyMessageRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
The message to be sent to a buddy.
The Buddy object corresponding to the message recipient.
An instance of containing additional custom parameters (e.g. the message color, an emoticon id, etc). Default is null.
See BuddyMessageRequest(String, Buddy, ISFSObject) constructor.
Toggles the current user's online/offline state as buddy in other users' buddies lists.
All clients who have the current user as buddy in their buddies list will receive the event and see the property change accordingly.
The same event is also dispatched to the current user, who sent the request, so that the application interface can be updated accordingly. Going online/offline as buddy doesn't affect the user connection, the currently joined Zone and Rooms, etc.
The online state of a user in a buddy list is handled by means of a reserved and persistent Buddy Variable.
This request can be sent if the Buddy List system was previously initialized only (see the request description).
The following example changes the user online state in the Buddy List system:
void SomeMethod() {
sfs.AddEventListener(SFSBuddyEvent.BUDDY_ONLINE_STATE_UPDATE, OnBuddyOnlineStateUpdate);
// Put myself offline in the Buddy List system
sfs.Send(new GoOnlineRequest(false));
}
void OnBuddyOnlineStateUpdate(BaseEvent evt) {
// As the state change event is dispatched to me too,
// I have to check if I am the one who changed his state
bool isItMe = (bool)evt.Params["isItMe"];
Buddy buddy = (Buddy)evt.Params["buddy"];
if (isItMe)
{
Console.WriteLine("I'm now " + (sfs.BuddyManager.MyOnlineState ? "online" : "offline")); // .Net / Unity
System.Diagnostics.Debug.WriteLine("I'm now " + (sfs.BuddyManager.MyOnlineState ? "online" : "offline")); // Windows Universal
}
else
{
Console.WriteLine("My buddy " + buddy.Name + " is now", (buddy.IsOnline ? "online" : "offline")); // .Net / Unity
System.Diagnostics.Debug.WriteLine("My buddy " + buddy.Name + " is now", (buddy.IsOnline ? "online" : "offline")); // Windows Universal
}
}
Creates a new GoOnlineRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
true to make the current user available (online) in the Buddy List system; false to make him not available (offline).
Initializes the Buddy List system on the current client.
Buddy List system initialization involves loading any previously stored buddy-specific data from the server, such as the current user's buddies list,
his previous state and the persistent Buddy Variables. The initialization request is the first operation to be executed in order to be able
to use the Buddy List system features. Once the initialization is completed, the event id fired
and the user has access to all his previously set data and can start to interact with his buddies; if the initialization failed, a event id fired.
The following example initializes the Buddy List system:
void SomeMethod() {
sfs.AddEventListener(SFSBuddyEvent.BUDDY_LIST_INIT, OnBuddyInited);
sfs.AddEventListener(SFSBuddyEvent.BUDDY_ERROR, OnBuddyError);
// Initialize the Buddy List system
sfs.Send(new InitBuddyListRequest());
}
void OnBuddyInited(BaseEvent evt) {
Console.WriteLine("Buddy List system initialized successfully"); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Buddy List system initialized successfully"); // Windows Universal
// Retrieve my buddies list
List<Buddy> buddies = sfs.BuddyManager.BuddyList;
// Display the online buddies in a list component in the application interface
...
}
void OnBuddyError(BaseEvent evt) {
Console.WriteLine("The following error occurred while executing a buddy-related request: " + (string)evt.Params["errorMessage"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("The following error occurred while executing a buddy-related request: " + (string)evt.Params["errorMessage"]); // Windows Universal
}
Creates a new InitBuddyListRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
Removes a buddy from the current user's buddies list.
In order to remove a buddy, the current user must be online in the Buddy List system. If the buddy is removed successfully,
the operation is confirmed by a event; otherwise the event is fired.
This request can be sent if the Buddy List system was previously initialized only (see the request description).
The following example sends a request to remove a buddy:
void SomeMethod() {
sfs.AddEventListener(SFSBuddyEvent.BUDDY_REMOVE, OnBuddyRemoved);
sfs.AddEventListener(SFSBuddyEvent.BUDDY_ERROR, OnBuddyError);
// Remove Jack from my buddies list
sfs.Send(new RemoveBuddyRequest("Jack"));
}
void OnBuddyRemoved(BaseEvent evt) {
Console.WriteLine("This buddy was removed: " + (Buddy)evt.Params["buddy"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("This buddy was removed: " + (Buddy)evt.Params["buddy"]); // Windows Universal
}
void OnBuddyError(BaseEvent evt) {
Console.WriteLine("The following error occurred while executing a buddy-related request: " + (string)evt.Params["errorMessage"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("The following error occurred while executing a buddy-related request: " + (string)evt.Params["errorMessage"]); // Windows Universal
}
Creates a new RemoveBuddyRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
The name of the buddy to be removed from the user's buddies list.
Sets one or more Buddy Variables for the current user.
This operation updates the Buddy object representing the user in all the buddies lists in which the user was added as a buddy.
If the operation is successful, a event is dispatched to all the
owners of those buddies lists and to the user who updated his variables too.
The Buddy Variables can be persisted, which means that their value will be saved even it the user disconnects and it will be restored when he connects again.
In order to make a variable persistent, put the constant SFSBuddyVariable.OFFLINE_PREFIX before its name.
Read the SmartFoxServer 2X documentaion about the Buddy List API for more informations.
This request can be sent if the Buddy List system was previously initialized only (see the request description) and the current user state in the system is "online".
The following example sets some Buddy Variables for the current user, one of which is persistent; the example also handles changes made by the user or by his buddies:
void SomeMethod() {
// Add event listener for BuddyVariables
sfs.AddEventListener(SFSBuddyEvent.BUDDY_VARIABLES_UPDATE, OnBuddyVarsUpdate);
// Create two Buddy Variables containing the title and artist of the song I'm listening to
BuddyVariable songTitle = new SFSBuddyVariable("songTitle", "Ascension");
BuddyVariable songAuthor = new SFSBuddyVariable("songAuthor", "Mike Oldfield");
// Create a persistent Buddy Variable containing my mood message
BuddyVariable mood = new SFSBuddyVariable(SFSBuddyVariable.OFFLINE_PREFIX + "mood", "I Need SmartFoxServer 2X desperately!");
// Set my Buddy Variables
List<BuddyVariable> myVars = new List<BuddyVariable>();
myVars.Add(songTitle);
myVars.Add(songAuthor);
myVars.Add(mood);
sfs.send(new SetBuddyVariablesRequest(myVars));
}
void OnBuddyVarsUpdate(BaseEvent evt) {
// As the update event is dispatched to me too,
// I have to check if I am the one who changed his Buddy Variables
Buddy buddy = (Buddy)evt.Params["buddy"]);
bool isItMe = (bool)evt.Params["isItMe"];
List<string> changedVars = (List<string>)evt.Params["changedVars"];
if (isItMe)
{
Console.WriteLine("I've updated the following Buddy Variables:"); // .Net / Unity
System.Diagnostics.Debug.WriteLine("I've updated the following Buddy Variables:"); // Windows Universal
for (int i = 0; i < changedVars.Count; i++)
{
string bVarName = changedVars[i];
Console.WriteLine(bVarName + ": " + sfs.BuddyManager.GetMyVariable(bVarName).Value()); // .Net / Unity
System.Diagnostics.Debug.WriteLine(bVarName + ": " + sfs.BuddyManager.GetMyVariable(bVarName).Value()); // Windows Universal
}
}
else
{
string buddyName = buddy.Name;
Console.WriteLine("My buddy " + buddyName + " updated the following Buddy Variables:"); // .Net / Unity
System.Diagnostics.Debug.WriteLine("My buddy " + buddyName + " updated the following Buddy Variables:"); // Windows Universal
for (int i = 0; i < changedVars.Count; i++)
{
var bVarName:String = changedVars[i];
Console.WriteLine(bVarName + ": " + sfs.BuddyManager.GetBuddyByName(buddyName).GetVariable(bVarName).Value()); // .Net / Unity
System.Diagnostics.Debug.WriteLine(bVarName + ": " + sfs.BuddyManager.GetBuddyByName(buddyName).GetVariable(bVarName).Value()); // Windows Universal
}
}
}
Creates a new SetBuddyVariablesRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
A list of objects representing the Buddy Variables to be set.
Creates a new public or private game, including player matching criteria, invitations settings and more.
A game is created through the istantiation of a SFSGame on the server-side, a specialized Room type that provides advanced features during the creation phase of a game.
Specific game-configuration settings are passed by means of the class.
If the creation is successful, a event is dispatched to all the users who subscribed the Group to which the Room is associated,
including the game creator. Otherwise, a event is returned to the creator's client.
Also, if the settings passed in the object cause invitations to join the game to be sent, an invitation event is dispatched to all the recipient clients.
Check the SmartFoxServer 2X documentation for a more in-depth overview of the GAME API.
The following example creates a new game:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.ROOM_ADD, OnRoomCreated);
sfs.AddEventListener(SFSEvent.ROOM_CREATION_ERROR, OnRoomError);
// Prepare the settings for a public game
SFSGameSettings settings = new SFSGameSettings("DartsGame");
settings.MaxUsers = 2;
settings.MaxSpectators = 8;
settings.IsPublic = true;
settings.MinPlayersToStartGame = 2;
settings.NotifyGameStarted = true;
// Set the matching expression to filter users joining the Room
settings.PlayerMatchExpression = new MatchExpression("bestScore", NumberMatch.GREATER_THAN, 100);
// Set a Room Variable containing the description of the game
List<RoomVariable> roomVars = new List<RoomVariable>();
roomVars.Add(new SFSRoomVariable("desc", "Darts game, public, bestScore > 100"));
settings.variables = roomVars;
// Create the game
smartFox.Send( new CreateSFSGameRequest(settings) );
}
void OnRoomCreated(BaseEvent evt) {
Console.WriteLine("Room created: " + (Room)evt.Params["room"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Room created: " + (Room)evt.Params["room"]); // Windows Universal
}
void OnRoomError(BaseEvent evt) {
Console.WriteLine("Room creation failed: " + (string)evt.Params["errorMessage"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Room creation failed: " + (string)evt.Params["errorMessage"]); // Windows Universal
}
Creates a new CreateSFSGameRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
An object containing the SFSGame configuration settings.
Replies to an invitation received by the current user.
Users who receive an invitation sent by means of the request can either accept or refuse it using this request.
The reply causes an event to be dispatched to the inviter; if a reply is not sent, or it is sent after the invitation expiration,
the system will react as if the invitation was refused.
If an error occurs while the reply is delivered to the inviter user (for example the invitation is already expired), an event is returned to the current user.
The following example receives an invitation and accepts it automatically; in a real case scenario, the application interface usually allows the user choosing to accept or refuse the invitation, or even ignore it:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.INVITATION, OnInvitationReceived);
sfs.AddEventListener(SFSEvent.INVITATION_REPLY_ERROR, OnInvitationReplyError);
}
void OnInvitationReceived(BaseEvent evt) {
// Let's accept this invitation
sfs.Send( new InvitationReplyRequest((Invitation)evt.Params["invitation"], InvitationReply.ACCEPT) );
}
void OnInvitationReplyError(BaseEvent evt) {
Console.WriteLine("Failed to reply to invitation due to the following problem: " + (string)evt.Params["errorMessage"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Failed to reply to invitation due to the following problem: " + (string)evt.Params["errorMessage"]); // Windows Universal
}
Creates a new InvitationReplyRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
An instance of the Invitation class containing the invitation details (inviter, custom parameters, etc).
The answer to be sent to the inviter, among those available as constants in the class.
An instance of containing custom parameters to be returned to the inviter together with the reply (for example a message describing the reason of refusal). Default is null.
See InvitationReplyRequest(Invitation, InvitationReply, ISFSObject) constructor.
Sends a generic invitation to a list of users.
Invitations can be used for different purposes, such as requesting users to join a game or visit a specific Room, asking the permission to add them as buddies, etc.
Invited users receive the invitation as an event dispatched to their clients: they can accept or refuse it
by means of the InvitationReplyRequest request, which must be sent within the specified amount of time.
The following example sends an invitation to join the current user in his private Room; the invitation contains a custom message and the Room name and password, so that the recipient clients can join the Room if the users accept the invitation:
void SomeMethod() {
// Add a listener to the invitation reply
sfs.AddEventListener(SFSEvent.INVITATION_REPLY, OnInvitationReply);
// Choose the invitation recipients
User friend1 = sfs.UserManager.GetUserByName("Piggy");
User friend2 = sfs.UserManager.GetUserByName("Gonzo");
List<object> invitedUsers = new List<object>();
invitedUsers.Add(user1);
invitedUsers.Add(user2);
// Set the custom invitation details
ISFSObject parameters = new SFSObject();
parameters.PutUtfString("msg", "Would you like to join me in my private room?");
parameters.PutUtfString("roomName", "Kermit's room");
parameters.PutUtfString("roomPwd", "drowssap");
// Send the invitation; recipients have 20 seconds to reply before the invitation expires
sfs.Send( new InviteUsersRequest(invitedUsers, 20, parameters) );
}
void OnInvitationReply(BaseEvent evt) {
// If at least one recipient accepted the invitation, make me join my private Room to meet him there
if ((InvitationReply)evt.Params["reply"] == InvitationReply.ACCEPT) {
Room currentRoom = sfs.LastJoinedRoom;
if (currentRoom.name != "Kermit's room")
sfs.Send(new JoinRoomRequest("Kermit's room"));
}
else ((InvitationReply)evt.Params["reply"] == InvitationReply.REFUSE) {
Console.WriteLine((User)evt.Params["invitee"] + " refused the invitation"); // .Net / Unity
System.Diagnostics.Debug.WriteLine((User)evt.Params["invitee"] + " refused the invitation"); // Windows Universal
}
}
Creates a new InviteUsersRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
A list of objects representing the users to send the invitation to.
The number of seconds available to each invited user to reply to the invitation (recommended range: 15 to 40 seconds).
An instance of containing custom parameters which specify the invitation details.
Quickly joins the current user in a public game.
By providing a matching expression and a list of Rooms or Groups, SmartFoxServer can search for a matching public Game Room and immediately join the user into that Room as a player.
If a game could be found and joined, the event is dispatched to the requester's client.
The following example makes the user quickly join a public game:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.ROOM_JOIN, onRoomJoin);
// Create a matching expression to find a Darts game with a "maxBet" variable less than 100
MatchExpression exp = new MatchExpression("type", StringMatch.EQUALS, "Darts").And("maxBet", NumberMatch.LESS_THAN, 100);
// Search and join a public game within the "games" Group, leaving the last joined Room
sfs.Send( new QuickJoinGameRequest(exp, new List<string>(){"games"}, sfs.LastJoinedRoom) );
}
void OnRoomJoin(BaseEvent evt) {
Console.WriteLine("Successfully joined Room: " + (Room)evt.Params["room"]); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Successfully joined Room: " + (Room)evt.Params["room"]); // Windows Universal
}
Creates a new QuickJoinGameRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
A matching expression that the system will use to search a Game Room where to join the current user.
A list of Group names to which the matching expression should be applied. The maximum number of elements in this list is 32.
An object representing the Room that the user should leave when joining the game. Default is null.
See QuickJoinGameRequest(MatchExpression, List<string>, Room) constructor.
Creates a new QuickJoinGameRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
A matching expression that the system will use to search a Game Room where to join the current user.
A list of Room objects to which the matching expression should be applied. The maximum number of elements in this list is 32.
An object representing the Room that the user should leave when joining the game. Default is null.
See QuickJoinGameRequest(MatchExpression, List<Room>, Room) constructor.
The SFSGameSettings class is a container for the settings required to create a Game Room using the CreateSFSGameRequest request.
On the server-side, a Game Room is represented by the SFSGame Java class which extends the class providing new advanced features such as player matching,
game invitations, public and private games, quick game joining, etc. On the client side Game Rooms are regular Rooms with their Room.IsGame property set to true.
Creates a new SFSGameSettings instance.
The instance must be passed to the class constructor.
The name of the Game Room to be created.
Indicates whether the game is public or private.
A public game can be joined by any player whose User Variables match the assigned to the Game Room.
A private game can be joined by users invited by the game creator by means of list.
The default value is true.
Defines the minimum number of players required to start the game.
If the property is set to true, when this number is reached, the game start is notified.
The default value is 2.
In private games, defines a list of User objects representing players to be invited to join the game.
If the invitations are less than the minimum number of players required to start the game (see the property),
the server will send additional invitations automatically, searching users in the Room Groups specified in the list
and filtering them by means of the object passed to the property.
The game matching criteria contained in the property do not apply to the users specified in this list.
The default value is null.
In private games, defines a list of Groups names where to search players to invite.
If the users invited to join the game (specified through the property) are less than the minimum number of players
required to start the game (see the property), the server will invite others automatically,
searching them in Rooms belonging to the Groups specified in this list and filtering them by means of the object passed to the property.
The default value is null.
In private games, defines the number of seconds that the users invited to join the game have to reply to the invitation.
The suggested range is 10 to 40 seconds. Default value is 15.
In private games, indicates whether the players must leave the previous Room when joining the game or not.
This setting applies to private games only because users join the Game Room automatically when they accept the invitation to play,
while public games require a request to be sent, where this behavior can be determined manually.
The default value is true.
Indicates if a game state change must be notified when the minimum number of players is reached.
If this setting is true, the game state (started or stopped) is handled by means of the reserved Room Variable represented by the ReservedRoomVariables.RV_GAME_STARTED constant.
Listening to the event for this variable allows clients to be notified when the game can start due to minimum number of players being reached.
As the used Room Variable is created as global (see the class description), its update is broadcast outside the Room too:
this can be used on the client-side, for example, to show the game state in a list of available games.
The default value is false.
Defines the game matching expression to be used to filters players.
Filtering is applied when:
- users try to join a public Game Room as players (their User Variables must match the matching criteria);
- the server selects additional users to be invited to join a private game (see the property).
Filtering is not applied to users invited by the creator to join a private game (see the property).
The default value is null.
Defines the game matching expression to be used to filters spectators.
Filtering is applied when users try to join a public Game Room as spectators (their User Variables must match the matching criteria).
The default value is null.
In private games, defines an optional object containing additional custom parameters to be sent together with the invitation.
This object must be an instance of . Possible custom parameters to be transferred to the invitees are a message
for the recipient, the game details (title, type...), the inviter details, etc.
The default value is null.
Sends an invitation to other users/players to join a specific Room.
Invited users receive the invitation as an event dispatched to their clients: they can accept or refuse it
by means of the InvitationReplyRequest request, which must be sent within the specified amount of time.
Depending on the Room's settings this invitation can be sent by the Room's owner only or by any other user.
This behavior can be set via the RoomSettings.AllowOwnerOnlyInvitation parameter.
NOTE: spectators in a Game Room are not allowed to invite other users; only players are.
An invitation can also specify the amount of time given to each invitee to reply. Default is 30 seconds.
A positive answer will attempt to join the user in the designated Room. For Game Rooms the asSpectator flag can be toggled to join the invitee as player or spectator (default = player).
There aren't any specific notifications sent back to the inviter after the invitee's response. Users that have accepted the invitation will join the Room while those who didn't reply or turned down the invitation won't generate any event.
In order to send specific messages (e.g. chat), just send a private message back to the inviter.
The following example invites two more users in the current game:
void SomeMethod() {
sfs.AddEventListener(SFSEvent.USER_ENTER_ROOM, onUserJoin);
List<string> invitedUsers = new List<string>(){"Fozzie", "Piggy"};
Room room = sfs.GetRoomByName("The Garden");
// Add message to be shown to the invited users
ISFSObject params = SFSObject.NewInstance();
params.PutUtfString("msg", "You are invited in this Room: " + room.Name);
// Send the request
sfs.Send( new JoinRoomInvitationRequest(room, invitedUsers, params) );
}
void onUserJoin(BaseEvent evt) {
User user = (User)evt.Params["user"];
Console.WriteLine("Room joined by: " + user.Name); // .Net / Unity
System.Diagnostics.Debug.WriteLine("Room joined by: " + user.Name); // Windows Universal
}
Creates a new JoinRoomInvitationRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
The Room to join (must have free user/player slots).
A list of user names to invite.
An instance of containing any relevant parameter or message to be sent to the invited users (for example an invitation message). Default is null.
The time given to the invitee to reply to the invitation. Default is 30.
In Game Rooms only, indicates if the invited user(s) should join as spectator(s) instead of player(s). Default is false.
See JoinRoomInvitationRequest(Room, List<string>, ISFSObject, int, bool) constructor.
See JoinRoomInvitationRequest(Room, List<string>, ISFSObject, int, bool) constructor.
See JoinRoomInvitationRequest(Room, List<string>, ISFSObject, int, bool) constructor.
The MMORoomSettings class is a container for the settings required to create an MMORoom using the CreateRoomRequest request.
Creates a new MMORoomSettings instance.
The instance must be passed to the class constructor.
The name of the MMORoom to be created.
Defines the Area of Interest (AoI) for the MMORoom.
This value represents the area/range around the user that will be affected by server events and other users events.
It is represented by a Vec3D object providing 2D or 3D coordinates.
Setting this value is mandatory.
A Vec3D(50,50) describes a range of 50 units (e.g. pixels) in all four directions (top, bottom, left, right) with respect to the user position in a 2D coordinates system.
A Vec3D(120,120,60) describes a range of 120 units in all four directions (top, bottom, left, right) and 60 units along the two Z-axis directions (backward, forward) with respect to the user position in a 3D coordinates system.
Defines the limits of the virtual environment represented by the MMORoom.
When specified, this property must contain two non-null Vec3D objects representing the minimum and maximum limits of the 2D/3D coordinates systems.
Any positional value that falls outside the provided limit will be refused by the server.
This setting is optional but its usage is highly recommended.
Defines the time limit before a user without a physical position set inside the MMORoom is kicked from the Room.
As soon as the MMORoom is joined, the user still doesn't have a physical position set in the coordinates system, therefore it is
considered in a "limbo" state. At this point the user is expected to set his position (via the request) within the amount of seconds expressed by this value.
The default value is 50 seconds.
Configures the speed at which the PROXIMITY_LIST_UPDATE event is sent by the server.
In an MMORoom, the regular users list is replaced by a proximity list, which keeps an updated view of the users currently within the Area of Interest
of the current user. The speed at which these updates are fired by the server is regulated by this parameter, which sets the minimum time between two subsequent updates.
The default value is 250 milliseconds.
NOTE: values below the default might be unnecessary for most applications unless they are in realtime.
Sets if the users entry points in the current user's Area of Interest should be transmitted in the PROXIMITY_LIST_UPDATE event.
If this setting is set to true, when a user enters the AoI of another user, the server will also send the coordinates
at which the former "appeared" within the AoI. This option should be turned off in case these coordinates are not needed, in order to save bandwidth.
The default value is true.
The MapLimits class is used to set the limits of the virtual environment represented by an MMORoom when creating it.
The limits represent the minimum and maximum coordinate values (2D or 3D) that the MMORoom should expect.
Creates a new MapLimits instance.
The property must be set to this instance during the MMORoom creation.
The lower coordinates limit of the virtual environment along the X,Y,Z axes.
The higher coordinates limit of the virtual environment along the X,Y,Z axes.
Returns the lower coordinates limit of the virtual environment along the X,Y,Z axes.
Returns the higher coordinates limit of the virtual environment along the X,Y,Z axes.
Updates the User position inside an MMORoom.
MMORooms represent virtual environments and can host any number of users. Based on their position, the system allows users within a certain range
from each other (Area of Interest, or AoI) to interact.
This request allows the current user to update his position inside the MMORoom, which in turn will trigger a
PROXIMITY_LIST_UPDATE event for all users that fall within his AoI.
The following example changes the position of the user in a 2D coordinates space and handles the related event:
private void UpdatePlayerPosition(int px, int py)
{
var newPos = new Vec3D(px, py);
sfs.send(new SetUserPositionRequest(newPos));
}
private void OnProximityListUpdate(BaseEvent evt)
{
var added = (List<User>) evt.params["addedUsers"];
var removed = (List<User>) evt.params["removedUsers"];
// Add users that entered the proximity list
foreach (User user in added)
{
// Obtain the coordinates at which the user "appeared" in our range
Vec3D entryPoint = user.AoiEntryPoint;
// Add new avatar in the scene
var avatarSprite = new AvatarSprite();
avatarSprite.x = entryPoint.px;
avatarSprite.y = entryPoint.py;
...
}
// Remove users that left the proximity list
foreach (User user in removed)
{
// Remove the avatar from the scene
...
}
}
Creates a new SetUserPositionRequest instance.
The instance must be passed to the SmartFox.Send method for the request to be performed.
The user position.
The MMORoom object corresponding to the Room where the position should be set; if null, the last Room joined by the user is used.
See SetUserPositionRequest(Vec3D, Room) constructor.
Provide information on the Online Status of the Buddy.
The Buddy is online.
The Buddy is offline in the Buddy List system.
The Buddy left the server.
The ClientDisconnectionReason class contains the costants describing the possible reasons why a disconnection from the server occurred.
Client was disconnected because it was idle for too long.
The connection timeout depends on the server settings.
Client was kicked out of the server.
Kicking can occur automatically (i.e. for swearing, if the words filter is active) or due to the intervention of a user with enough privileges (i.e. an administrator or a moderator).
Client was banned from the server.
Banning can occur automatically (i.e. for flooding, if the flood filter is active) or due to the intervention of a user with enough privileges (i.e. an administrator or a moderator).
The client manually disconnected from the server.
The method on the SmartFox class was called.
A generic network error occurred, and the client is unable to determine the cause of the disconnection.
The server-side log should be checked for possible error messages or warnings.
The ConfigData class stores the client configuration data loaded from an external XML file or passed directly to the deputy connect method.
The external configuration file is loaded by the SmartFox class when its SmartFox.LoadConfig() method is called.
Otherwise it can be passed directly to one of the SmartFox.Connect(ConfigData) method overloads of the SmartFox class.
Creates a new ConfigData instance.
Specifies the IP address or host name of the SmartFoxServer 2X instance to connect to (TCP connection).
The default value is 127.0.0.1.
When using a websocket connection to an IPv6 address, always wrap the address in square brackets.
Specifies the TCP port of the SmartFoxServer 2X instance to connect to (TCP connection).
The default value is 9933.
Specifies the IP address of the SmartFoxServer 2X instance to connect to (UDP connection).
The default value is 127.0.0.1.
Specifies the UDP port of the SmartFoxServer 2X instance to connect to (UDP connection).
The default value is 9933.
Specifies the Zone of the SmartFoxServer 2X instance to join.
The default value is null.
Indicates whether the client-server messages debug should be enabled or not.
The default value is false.
Specifies the port for generic HTTP communication.
The default value is 8080.
Specifies the port for HTTPS communication.
For example this parameter is required during the initialization of an encrypted connection.
The default value is 8443.
Indicates whether the SmartFoxServer's BlueBox should be enabled or not.
The default value is true.
Specifies the BlueBox polling speed.
The default value is 750.
Indicates whether SmartFoxServer's TCP socket is using the Nagle algorithm or not.
This setting must be false to use the Nagle algorithm; otherwise, true.
The default value is false.
By default load a file called sfs-config.xml located in the same folder of the application
Path to config file
Helper class for logging in with a pre-hashed password.
This is needed if your server-side database stores User passwords hashed with MD5.
For more information see the Sign Up Assistant component tutorial (Password Mode section).
Generates the MD5 hash of the user password.
The plain text password.
The hashed password.
string userName = "testName";
string userPass = "testPass";
string md5Pass = PasswordUtil.MD5Password(userPass);
sfs.Send(new LoginRequest(userName, md5Pass, sfs.Config.Zone));
The SFSErrorCodes class provides a mean of translation between server error codes and their relative error messages.
Error messages are provided by default in the English language but they can be localized and substituted in any other language.
The error messages contain special placeholders that are processed at runtime and substituted with runtime data.
They are in the form of a number enclosed in curly brackets such as: {0}, {1}, etc. Please make sure you maintain these placeholders while translating the messages.
For more informations please visit this link: http://docs2x.smartfoxserver.com/AdvancedTopics/client-error-messages.
Sets the text of the error message corresponding to the passed error code.
Make sure to maintain all the placeholders while modifying the messages.
The code of the error message to be modified.
The new error message, including the placeholders for runtime informations.
The following example shows how to translate error 13 to French language retaining the required placeholders:
SFSErrorCodes.SetErrorMessage(13, "Le Groupe demandé n'est pas disponible - Salle: {0}; Groupe: {1}");
The available websocket connection modes to be passed to the SmartFox class constructor.
Unsecure, text-type websocket communication should be established when connecting to a SmartFoxServer 2X instance.
Secure, text-type websocket communication should be established when connecting to a SmartFoxServer 2X instance.
Unsecure, binary-type websocket communication should be established when connecting to a SmartFoxServer 2X instance.
Secure, binary-type websocket communication should be established when connecting to a SmartFoxServer 2X instance.
This method returns the literal value received
The literal to return
The received value
This method returns the literal value received
The literal to return
The received value
This method returns the literal value received
The literal to return
The received value
This method returns the literal value received
The literal to return
The received value
Performs an unsigned bitwise right shift with the specified number
Number to operate on
Ammount of bits to shift
The resulting number from the shift operation
Performs an unsigned bitwise right shift with the specified number
Number to operate on
Ammount of bits to shift
The resulting number from the shift operation
Performs an unsigned bitwise right shift with the specified number
Number to operate on
Ammount of bits to shift
The resulting number from the shift operation
Performs an unsigned bitwise right shift with the specified number
Number to operate on
Ammount of bits to shift
The resulting number from the shift operation
Reads a number of characters from the current source Stream and writes the data to the target array at the specified index.
The source Stream to read from.
Contains the array of characteres read from the source Stream.
The starting index of the target array.
The maximum number of characters to read from the source Stream.
The number of characters read. The number will be less than or equal to count depending on the data available in the source Stream. Returns -1 if the end of the stream is reached.
Reads a number of characters from the current source TextReader and writes the data to the target array at the specified index.
The source TextReader to read from
Contains the array of characteres read from the source TextReader.
The starting index of the target array.
The maximum number of characters to read from the source TextReader.
The number of characters read. The number will be less than or equal to count depending on the data available in the source TextReader. Returns -1 if the end of the stream is reached.
Converts a string to an array of bytes
The string to be converted
The new array of bytes
Converts an array of bytes to an array of chars
The array of bytes to convert
The new array of chars
Returns the total number of bytes input so far.
Returns the total number of bytes output so far.
Returns the total number of bytes input so far.
Returns the total number of bytes output so far.
Contains the values that indicate whether the byte order is a Little-endian or Big-endian.
Indicates a Little-endian.
Indicates a Big-endian.
Contains the event data associated with a event.
A event occurs when the WebSocket connection has been
closed.
If you would like to get the reason for the close, you should access
the or property.
Gets the status code for the close.
A that represents the status code for the close if any.
Gets the reason for the close.
A that represents the reason for the close if any.
Gets a value indicating whether the WebSocket connection has been closed cleanly.
true if the WebSocket connection has been closed cleanly; otherwise, false.
Contains the values of the status code for the WebSocket connection close.
The values of the status code are defined in
Section 7.4
of RFC 6455.
"Reserved value" must not be set as a status code in a close control frame
by an endpoint. It's designated for use in applications expecting a status
code to indicate that the connection was closed due to the system grounds.
Equivalent to close status 1000.
Indicates a normal close.
Equivalent to close status 1001.
Indicates that an endpoint is going away.
Equivalent to close status 1002.
Indicates that an endpoint is terminating the connection due to a protocol error.
Equivalent to close status 1003.
Indicates that an endpoint is terminating the connection because it has received
an unacceptable type message.
Equivalent to close status 1004.
Still undefined. A Reserved value.
Equivalent to close status 1005.
Indicates that no status code was actually present. A Reserved value.
Equivalent to close status 1006.
Indicates that the connection was closed abnormally. A Reserved value.
Equivalent to close status 1007.
Indicates that an endpoint is terminating the connection because it has received
a message that contains a data that isn't consistent with the type of the message.
Equivalent to close status 1008.
Indicates that an endpoint is terminating the connection because it has received
a message that violates its policy.
Equivalent to close status 1009.
Indicates that an endpoint is terminating the connection because it has received
a message that is too big to process.
Equivalent to close status 1010.
Indicates that the client is terminating the connection because it has expected
the server to negotiate one or more extension, but the server didn't return them
in the handshake response.
Equivalent to close status 1011.
Indicates that the server is terminating the connection because it has encountered
an unexpected condition that prevented it from fulfilling the request.
Equivalent to close status 1015.
Indicates that the connection was closed due to a failure to perform a TLS handshake.
A Reserved value.
Contains the values of the compression method used to compress the message on the WebSocket
connection.
The values of the compression method are defined in
Compression
Extensions for WebSocket.
Indicates non compression.
Indicates using DEFLATE.
Contains the event data associated with a event.
A event occurs when the gets
an error.
If you would like to get the error message, you should access
the property.
And if the error is due to an exception, you can get the
instance by accessing the property.
Gets the instance that caused the error.
An instance that represents the cause of the error,
or if the error isn't due to an exception.
Gets the error message.
A that represents the error message.
Provides a set of static methods for websocket-sharp.
Determines whether the specified equals the specified ,
and invokes the specified Action<int> delegate at the same time.
true if equals ;
otherwise, false.
An to compare.
A to compare.
An Action<int> delegate that references the method(s) called
at the same time as comparing. An parameter to pass to
the method(s) is .
Gets the absolute path from the specified .
A that represents the absolute path if it's successfully found;
otherwise, .
A that represents the URI to get the absolute path from.
Gets the name from the specified that contains a pair of name and
value separated by a separator character.
A that represents the name if any; otherwise, null.
A that contains a pair of name and value separated by a separator
character.
A that represents the separator character.
Gets the value from the specified that contains a pair of name and
value separated by a separator character.
A that represents the value if any; otherwise, null.
A that contains a pair of name and value separated by a separator
character.
A that represents the separator character.
Tries to create a for WebSocket with the specified
.
true if a is successfully created; otherwise, false.
A that represents the WebSocket URL to try.
When this method returns, a that represents the WebSocket URL
if is valid; otherwise, .
When this method returns, a that represents the error message
if is invalid; otherwise, .
Determines whether the specified contains any of characters
in the specified array of .
true if contains any of ;
otherwise, false.
A to test.
An array of that contains characters to find.
Determines whether the specified contains the entry
with the specified .
true if contains the entry
with ; otherwise, false.
A to test.
A that represents the key of the entry to find.
Determines whether the specified contains the entry
with the specified both and .
true if contains the entry with both
and ; otherwise, false.
A to test.
A that represents the key of the entry to find.
A that represents the value of the entry to find.
Emits the specified delegate if it isn't .
A to emit.
An from which emits this .
A that contains no event data.
Emits the specified EventHandler<TEventArgs> delegate
if it isn't .
An EventHandler<TEventArgs> to emit.
An from which emits this .
A TEventArgs that represents the event data.
The type of the event data generated by the event.
Gets the collection of the HTTP cookies from the specified HTTP .
A that receives a collection of the HTTP cookies.
A that contains a collection of the HTTP headers.
true if is a collection of the response headers;
otherwise, false.
Gets the description of the specified HTTP status .
A that represents the description of the HTTP status code.
One of enum values, indicates the HTTP status code.
Gets the description of the specified HTTP status .
A that represents the description of the HTTP status code.
An that represents the HTTP status code.
Determines whether the specified is in the allowable range of
the WebSocket close status code.
Not allowable ranges are the following:
-
Numbers in the range 0-999 are not used.
-
Numbers greater than 4999 are out of the reserved close status code ranges.
true if is in the allowable range of the WebSocket
close status code; otherwise, false.
A to test.
Determines whether the specified is enclosed in the specified
.
true if is enclosed in ;
otherwise, false.
A to test.
A that represents the character to find.
Determines whether the specified is host (this computer
architecture) byte order.
true if is host byte order; otherwise, false.
One of the enum values, to test.
Determines whether the specified represents
the local IP address.
true if represents the local IP address;
otherwise, false.
A to test.
is .
Determines whether the specified is or empty.
true if is or empty;
otherwise, false.
A to test.
Determines whether the specified is a predefined scheme.
true if is a predefined scheme; otherwise, false.
A to test.
Determines whether the specified is an HTTP Upgrade
request to switch to the specified .
true if is an HTTP Upgrade request to switch to
; otherwise, false.
A that represents the HTTP request.
A that represents the protocol name.
is .
-or-
is .
is empty.
Determines whether the specified is a URI string.
true if may be a URI string; otherwise, false.
A to test.
Retrieves a sub-array from the specified .
A sub-array starts at the specified element position in .
An array of T that receives a sub-array, or an empty array of T
if any problems with the parameters.
An array of T from which to retrieve a sub-array.
An that represents the zero-based starting position of
a sub-array in .
An that represents the number of elements to retrieve.
The type of elements in .
Retrieves a sub-array from the specified .
A sub-array starts at the specified element position in .
An array of T that receives a sub-array, or an empty array of T
if any problems with the parameters.
An array of T from which to retrieve a sub-array.
A that represents the zero-based starting position of
a sub-array in .
A that represents the number of elements to retrieve.
The type of elements in .
Executes the specified delegate times.
An is the number of times to execute.
An delegate that references the method(s) to execute.
Executes the specified delegate times.
A is the number of times to execute.
An delegate that references the method(s) to execute.
Executes the specified delegate times.
A is the number of times to execute.
An delegate that references the method(s) to execute.
Executes the specified delegate times.
A is the number of times to execute.
An delegate that references the method(s) to execute.
Executes the specified Action<int> delegate times.
An is the number of times to execute.
An Action<int> delegate that references the method(s) to execute.
An parameter to pass to the method(s) is the zero-based count
of iteration.
Executes the specified Action<long> delegate times.
A is the number of times to execute.
An Action<long> delegate that references the method(s) to execute.
A parameter to pass to the method(s) is the zero-based count
of iteration.
Executes the specified Action<uint> delegate times.
A is the number of times to execute.
An Action<uint> delegate that references the method(s) to execute.
A parameter to pass to the method(s) is the zero-based count
of iteration.
Executes the specified Action<ulong> delegate times.
A is the number of times to execute.
An Action<ulong> delegate that references the method(s) to execute.
A parameter to pass to this method(s) is the zero-based count
of iteration.
Converts the specified array of to the specified type data.
A T converted from , or a default value of T if
is an empty array of or if the
type of T isn't , , ,
, , , ,
, , or .
An array of to convert.
One of the enum values, indicates the byte order of
.
The type of the return. The T must be a value type.
is .
Converts the specified to an array of .
An array of converted from .
A T to convert.
One of the enum values, indicates the byte order of the return.
The type of . The T must be a value type.
Converts the order of the specified array of to the host byte order.
An array of converted from .
An array of to convert.
One of the enum values, indicates the byte order of
.
is .
Converts the specified to a
that concatenates the each element of across the
specified .
A converted from ,
or if is empty.
An array of T to convert.
A that represents the separator string.
The type of elements in .
is .
Converts the specified to a .
A converted from , or
if isn't successfully converted.
A to convert.
URL-decodes the specified .
A that receives the decoded string, or the
if it's or empty.
A to decode.
URL-encodes the specified .
A that receives the encoded string, or
if it's or empty.
A to encode.
Writes the specified data with the specified
.
A that represents the HTTP response
used to write the content data.
An array of that represents the content data to write.
is .
Represents a log data used by the class.
Gets the information of the logging method caller.
A that provides the information of the logging method caller.
Gets the date and time when the log data was created.
A that represents the date and time when the log data was created.
Gets the logging level of the log data.
One of the enum values, indicates the logging level of the log data.
Gets the message of the log data.
A that represents the message of the log data.
Returns a that represents the current .
A that represents the current .
Contains the values of the logging level.
Indicates the bottom logging level.
Indicates the 2nd logging level from the bottom.
Indicates the 3rd logging level from the bottom.
Indicates the 3rd logging level from the top.
Indicates the 2nd logging level from the top.
Indicates the top logging level.
Provides a set of methods and properties for logging.
If you output a log with lower than the ,
it cannot be outputted.
The default output action writes a log to the standard output stream and
the if it has a valid path.
If you would like to use the custom output action, you should set the
to any Action<LogData, string> delegate.
Initializes a new instance of the class.
This constructor initializes the current logging level with .
Initializes a new instance of the class with the specified
logging .
One of the enum values.
Initializes a new instance of the class with the specified
logging , path to the log , and
action.
One of the enum values.
A that represents the path to the log file.
An Action<LogData, string> delegate that references the method(s)
used to output a log. A parameter passed to this delegate
is .
Gets or sets the current path to the log file.
A that represents the current path to the log file if any.
Gets or sets the current logging level.
A log with lower than the value of this property cannot be outputted.
One of the enum values, indicates the current logging level.
Gets or sets the current output action used to output a log.
An Action<LogData, string> delegate that references the method(s) used to
output a log. A parameter passed to this delegate is the value of
the .
If the value to set is , the current output action is changed to
the default output action.
Outputs as a log with .
If the current logging level is higher than ,
this method doesn't output as a log.
A that represents the message to output as a log.
Outputs as a log with .
If the current logging level is higher than ,
this method doesn't output as a log.
A that represents the message to output as a log.
Outputs as a log with .
A that represents the message to output as a log.
Outputs as a log with .
If the current logging level is higher than ,
this method doesn't output as a log.
A that represents the message to output as a log.
Outputs as a log with .
If the current logging level is higher than ,
this method doesn't output as a log.
A that represents the message to output as a log.
Outputs as a log with .
If the current logging level is higher than ,
this method doesn't output as a log.
A that represents the message to output as a log.
Contains the event data associated with a event.
A event occurs when the receives
a text or binary message.
If you would like to get the message data, you should access
the or property.
Gets the message data as a .
If the message data is empty, this property returns .
Or if the message is a binary message, this property returns "Binary".
A that represents the message data.
Gets the message data as an array of .
An array of that represents the message data.
Gets the type of the message.
or .
Contains the values of the opcode that indicates the type of a WebSocket frame.
The values of the opcode are defined in
Section 5.2 of RFC 6455.
Equivalent to numeric value 0.
Indicates a continuation frame.
Equivalent to numeric value 1.
Indicates a text frame.
Equivalent to numeric value 2.
Indicates a binary frame.
Equivalent to numeric value 8.
Indicates a connection close frame.
Equivalent to numeric value 9.
Indicates a ping frame.
Equivalent to numeric value 10.
Indicates a pong frame.
Implements the WebSocket interface.
The WebSocket class provides a set of methods and properties for two-way communication using
the WebSocket protocol (RFC 6455).
Initializes a new instance of the class with
the specified WebSocket URL and subprotocols.
A that represents the WebSocket URL to connect.
An array of that contains the WebSocket subprotocols if any.
Each value of must be a token defined in
RFC 2616.
is invalid.
-or-
is invalid.
is .
Gets or sets the compression method used to compress the message on the WebSocket
connection.
One of the enum values, indicates the compression method
used to compress the message. The default value is .
Gets the HTTP cookies included in the WebSocket connection request and response.
An
instance that provides an enumerator which supports the iteration over the collection of
the cookies.
Gets the credentials for the HTTP authentication (Basic/Digest).
A that represents the credentials for the authentication.
The default value is .
Gets or sets a value indicating whether the redirects to
the new URL located in the handshake response.
true if the redirects to the new URL;
otherwise, false. The default value is false.
Gets the WebSocket extensions selected by the server.
A that represents the extensions if any.
The default value is .
Gets a value indicating whether the WebSocket connection is alive.
true if the connection is alive; otherwise, false.
Gets a value indicating whether the WebSocket connection is secure.
true if the connection is secure; otherwise, false.
Gets the logging functions.
The default logging level is . If you would like to change it,
you should set the Log.Level property to any of the enum
values.
A that provides the logging functions.
Gets or sets the value of the HTTP Origin header to send with the WebSocket connection
request to the server.
The sends the Origin header if this property has any.
A that represents the value of
the Origin header to send.
The default value is .
The Origin header has the following syntax:
<scheme>://<host>[:<port>]
Gets the WebSocket subprotocol selected by the server.
A that represents the subprotocol if any.
The default value is .
Gets the state of the WebSocket connection.
One of the enum values, indicates the state of the WebSocket
connection. The default value is .
Gets or sets the SSL configuration used to authenticate the server and
optionally the client for secure connection.
A that represents the configuration used
to authenticate the server and optionally the client for secure connection,
or if the is used as server.
Gets the WebSocket URL to connect.
A that represents the WebSocket URL to connect.
Gets or sets the wait time for the response to the Ping or Close.
A that represents the wait time. The default value is
the same as 5 seconds, or 1 second if the is used by
a server.
Occurs when the WebSocket connection has been closed.
Occurs when the gets an error.
Occurs when the receives a message.
Occurs when the WebSocket connection has been established.
Closes the WebSocket connection, and releases all associated resources.
Closes the WebSocket connection with the specified ,
and releases all associated resources.
This method emits a event if
isn't in the allowable range of the close status code.
A that represents the status code indicating the reason
for the close.
Closes the WebSocket connection with the specified ,
and releases all associated resources.
One of the enum values, represents the status code
indicating the reason for the close.
Closes the WebSocket connection with the specified
and , and releases all associated resources.
This method emits a event if
isn't in the allowable range of the close status code or the size of
is greater than 123 bytes.
A that represents the status code indicating the reason
for the close.
A that represents the reason for the close.
Closes the WebSocket connection with the specified
and , and releases all associated resources.
This method emits a event if the size of
is greater than 123 bytes.
One of the enum values, represents the status code
indicating the reason for the close.
A that represents the reason for the close.
Closes the WebSocket connection asynchronously, and releases all associated resources.
This method doesn't wait for the close to be complete.
Closes the WebSocket connection asynchronously with the specified ,
and releases all associated resources.
This method doesn't wait for the close to be complete.
This method emits a event if isn't in
the allowable range of the close status code.
A that represents the status code indicating the reason for the close.
Closes the WebSocket connection asynchronously with the specified
, and releases all associated resources.
This method doesn't wait for the close to be complete.
One of the enum values, represents the status code
indicating the reason for the close.
Closes the WebSocket connection asynchronously with the specified
and , and releases all associated resources.
This method doesn't wait for the close to be complete.
This method emits a event if isn't in
the allowable range of the close status code or the size of
is greater than 123 bytes.
A that represents the status code indicating the reason for the close.
A that represents the reason for the close.
Closes the WebSocket connection asynchronously with the specified
and , and releases
all associated resources.
This method doesn't wait for the close to be complete.
This method emits a event if the size of
is greater than 123 bytes.
One of the enum values, represents the status code
indicating the reason for the close.
A that represents the reason for the close.
Establishes a WebSocket connection.
Establishes a WebSocket connection asynchronously.
This method doesn't wait for the connect to be complete.
Sends a Ping using the WebSocket connection.
true if the receives a Pong to this Ping in a time;
otherwise, false.
Sends a Ping with the specified using the WebSocket connection.
true if the receives a Pong to this Ping in a time;
otherwise, false.
A that represents the message to send.
Sends a binary using the WebSocket connection.
An array of that represents the binary data to send.
Sends the specified as a binary data
using the WebSocket connection.
A that represents the file to send.
Sends a text using the WebSocket connection.
A that represents the text data to send.
Sends a binary asynchronously using the WebSocket connection.
This method doesn't wait for the send to be complete.
An array of that represents the binary data to send.
An Action<bool> delegate that references the method(s) called when
the send is complete. A passed to this delegate is true
if the send is complete successfully.
Sends the specified as a binary data asynchronously
using the WebSocket connection.
This method doesn't wait for the send to be complete.
A that represents the file to send.
An Action<bool> delegate that references the method(s) called when
the send is complete. A passed to this delegate is true
if the send is complete successfully.
Sends a text asynchronously using the WebSocket connection.
This method doesn't wait for the send to be complete.
A that represents the text data to send.
An Action<bool> delegate that references the method(s) called when
the send is complete. A passed to this delegate is true
if the send is complete successfully.
Sends a binary data from the specified asynchronously
using the WebSocket connection.
This method doesn't wait for the send to be complete.
A from which contains the binary data to send.
An that represents the number of bytes to send.
An Action<bool> delegate that references the method(s) called when
the send is complete. A passed to this delegate is true
if the send is complete successfully.
Sets an HTTP to send with the WebSocket connection request
to the server.
A that represents the cookie to send.
Sets a pair of and for
the HTTP authentication (Basic/Digest).
A that represents the user name used to authenticate.
A that represents the password for
used to authenticate.
true if the sends the Basic authentication credentials
with the first connection request to the server; otherwise, false.
Sets an HTTP Proxy server URL to connect through, and if necessary, a pair of
and for the proxy server
authentication (Basic/Digest).
A that represents the proxy server URL to connect through.
A that represents the user name used to authenticate.
A that represents the password for
used to authenticate.
Closes the WebSocket connection, and releases all associated resources.
This method closes the connection with .
The exception that is thrown when a gets a fatal error.
Gets the status code indicating the cause of the exception.
One of the enum values, represents the status code
indicating the cause of the exception.
Contains the values of the state of the WebSocket connection.
The values of the state are defined in
The WebSocket API.
Equivalent to numeric value 0.
Indicates that the connection hasn't yet been established.
Equivalent to numeric value 1.
Indicates that the connection is established and the communication is possible.
Equivalent to numeric value 2.
Indicates that the connection is going through the closing handshake or
the WebSocket.Close method has been invoked.
Equivalent to numeric value 3.
Indicates that the connection has been closed or couldn't be opened.
Contains the values of the schemes for authentication.
Indicates that no authentication is allowed.
Indicates digest authentication.
Indicates basic authentication.
Indicates anonymous authentication.
Stores the parameters used to configure a instance as a client.
Initializes a new instance of the class with
the specified .
A that represents the name of the server that shares
a secure connection.
Initializes a new instance of the class with
the specified , ,
, and .
A that represents the name of the server that shares
a secure connection.
A that contains client certificates.
The enum value that represents the protocols used for
authentication.
true if the certificate revocation list is checked during authentication;
otherwise, false.
Gets or sets the collection that contains client certificates.
A that contains client certificates.
Gets or sets the callback used to select a client certificate to supply to the server.
If this callback returns , no client certificate will be supplied.
A delegate that references the method
used to select the client certificate. The default value is a function that only returns
.
Gets or sets the callback used to validate the certificate supplied by the server.
If this callback returns true, the server certificate will be valid.
A delegate that references the method
used to validate the server certificate. The default value is a function that only returns
true.
Gets or sets the name of the server that shares a secure connection.
A that represents the name of the server that shares
a secure connection.
Provides a set of methods and properties used to manage an HTTP Cookie.
The Cookie class supports the following cookie formats:
Netscape specification,
RFC 2109, and
RFC 2965
The Cookie class cannot be inherited.
Initializes a new instance of the class.
Initializes a new instance of the class with the specified
and .
A that represents the Name of the cookie.
A that represents the Value of the cookie.
is or empty.
- or -
contains an invalid character.
- or -
is .
- or -
contains a string not enclosed in double quotes
that contains an invalid character.
Initializes a new instance of the class with the specified
, , and .
A that represents the Name of the cookie.
A that represents the Value of the cookie.
A that represents the value of the Path attribute of the cookie.
is or empty.
- or -
contains an invalid character.
- or -
is .
- or -
contains a string not enclosed in double quotes
that contains an invalid character.
Initializes a new instance of the class with the specified
, , , and
.
A that represents the Name of the cookie.
A that represents the Value of the cookie.
A that represents the value of the Path attribute of the cookie.
A that represents the value of the Domain attribute of the cookie.
is or empty.
- or -
contains an invalid character.
- or -
is .
- or -
contains a string not enclosed in double quotes
that contains an invalid character.
Gets or sets the value of the Comment attribute of the cookie.
A that represents the comment to document intended use of the cookie.
Gets or sets the value of the CommentURL attribute of the cookie.
A that represents the URI that provides the comment to document intended
use of the cookie.
Gets or sets a value indicating whether the client discards the cookie unconditionally
when the client terminates.
true if the client discards the cookie unconditionally when the client terminates;
otherwise, false. The default value is false.
Gets or sets the value of the Domain attribute of the cookie.
A that represents the URI for which the cookie is valid.
Gets or sets a value indicating whether the cookie has expired.
true if the cookie has expired; otherwise, false.
The default value is false.
Gets or sets the value of the Expires attribute of the cookie.
A that represents the date and time at which the cookie expires.
The default value is .
Gets or sets a value indicating whether non-HTTP APIs can access the cookie.
true if non-HTTP APIs cannot access the cookie; otherwise, false.
The default value is false.
Gets or sets the Name of the cookie.
A that represents the Name of the cookie.
The value specified for a set operation is or empty.
- or -
The value specified for a set operation contains an invalid character.
Gets or sets the value of the Path attribute of the cookie.
A that represents the subset of URI on the origin server
to which the cookie applies.
Gets or sets the value of the Port attribute of the cookie.
A that represents the list of TCP ports to which the cookie applies.
The value specified for a set operation isn't enclosed in double quotes or
couldn't be parsed.
Gets or sets a value indicating whether the security level of the cookie is secure.
When this property is true, the cookie may be included in the HTTP request
only if the request is transmitted over the HTTPS.
true if the security level of the cookie is secure; otherwise, false.
The default value is false.
Gets the time when the cookie was issued.
A that represents the time when the cookie was issued.
Gets or sets the Value of the cookie.
A that represents the Value of the cookie.
The value specified for a set operation is .
- or -
The value specified for a set operation contains a string not enclosed in double quotes
that contains an invalid character.
Gets or sets the value of the Version attribute of the cookie.
An that represents the version of the HTTP state management
to which the cookie conforms.
The value specified for a set operation isn't 0 or 1.
Determines whether the specified is equal to the current
.
An to compare with the current .
true if is equal to the current ;
otherwise, false.
Serves as a hash function for a object.
An that represents the hash code for the current .
Returns a that represents the current .
This method returns a to use to send an HTTP Cookie to
an origin server.
A that represents the current .
Provides a collection container for instances of the class.
Initializes a new instance of the class.
Gets the number of cookies in the collection.
An that represents the number of cookies in the collection.
Gets a value indicating whether the collection is read-only.
true if the collection is read-only; otherwise, false.
The default value is true.
Gets a value indicating whether the access to the collection is thread safe.
true if the access to the collection is thread safe; otherwise, false.
The default value is false.
Gets the at the specified from
the collection.
A at the specified in the collection.
An that represents the zero-based index of the
to find.
is out of allowable range of indexes for the collection.
Gets the with the specified from
the collection.
A with the specified in the collection.
A that represents the name of the to find.
is .
Gets an object used to synchronize access to the collection.
An used to synchronize access to the collection.
Adds the specified to the collection.
A to add.
is .
Adds the specified to the collection.
A that contains the cookies to add.
is .
Copies the elements of the collection to the specified , starting at
the specified in the .
An that represents the destination of the elements copied from
the collection.
An that represents the zero-based index in
at which copying begins.
is .
is less than zero.
is multidimensional.
-or-
The number of elements in the collection is greater than the available space from
to the end of the destination .
The elements in the collection cannot be cast automatically to the type of the destination
.
Copies the elements of the collection to the specified array of ,
starting at the specified in the .
An array of that represents the destination of the elements
copied from the collection.
An that represents the zero-based index in
at which copying begins.
is .
is less than zero.
The number of elements in the collection is greater than the available space from
to the end of the destination .
Gets the enumerator used to iterate through the collection.
An instance used to iterate through the collection.
The exception that is thrown when a gets an error.
Initializes a new instance of the class from
the specified and .
A that contains the serialized object data.
A that specifies the source for the deserialization.
Initializes a new instance of the class.
Populates the specified with the data needed to serialize
the current .
A that holds the serialized object data.
A that specifies the destination for the serialization.
Populates the specified with the data needed to serialize
the current .
A that holds the serialized object data.
A that specifies the destination for the serialization.
Holds the user name and password from the HTTP Basic authentication credentials.
Gets the password from the HTTP Basic authentication credentials.
A that represents the password.
Holds the user name and other parameters from the HTTP Digest authentication credentials.
Gets the algorithm parameter from the HTTP Digest authentication credentials.
A that represents the algorithm parameter.
Gets the cnonce parameter from the HTTP Digest authentication credentials.
A that represents the cnonce parameter.
Gets the nc parameter from the HTTP Digest authentication credentials.
A that represents the nc parameter.
Gets the nonce parameter from the HTTP Digest authentication credentials.
A that represents the nonce parameter.
Gets the opaque parameter from the HTTP Digest authentication credentials.
A that represents the opaque parameter.
Gets the qop parameter from the HTTP Digest authentication credentials.
A that represents the qop parameter.
Gets the realm parameter from the HTTP Digest authentication credentials.
A that represents the realm parameter.
Gets the response parameter from the HTTP Digest authentication credentials.
A that represents the response parameter.
Gets the uri parameter from the HTTP Digest authentication credentials.
A that represents the uri parameter.
Provides a simple, programmatically controlled HTTP listener.
Initializes a new instance of the class.
Gets or sets the scheme used to authenticate the clients.
One of the enum values,
represents the scheme used to authenticate the clients. The default value is
.
This listener has been closed.
Gets or sets the delegate called to select the scheme used to authenticate the clients.
If you set this property, the listener uses the authentication scheme selected by
the delegate for each request. Or if you don't set, the listener uses the value of
the property as the authentication
scheme for all requests.
A Func<, >
delegate that references the method used to select an authentication scheme. The default
value is .
This listener has been closed.
Gets or sets the path to the folder in which stores the certificate files used to
authenticate the server on the secure connection.
This property represents the path to the folder in which stores the certificate files
associated with each port number of added URI prefixes. A set of the certificate files
is a pair of the 'port number'.cer (DER) and 'port number'.key
(DER, RSA Private Key).
If this property is or empty, the result of
System.Environment.GetFolderPath
() is used as the default path.
A that represents the path to the folder in which stores
the certificate files. The default value is .
This listener has been closed.
Gets or sets a value indicating whether the listener returns exceptions that occur when
sending the response to the client.
true if the listener shouldn't return those exceptions; otherwise, false.
The default value is false.
This listener has been closed.
Gets a value indicating whether the listener has been started.
true if the listener has been started; otherwise, false.
Gets a value indicating whether the listener can be used with the current operating system.
true.
Gets the logging functions.
The default logging level is . If you would like to change it,
you should set the Log.Level property to any of the enum
values.
A that provides the logging functions.
Gets the URI prefixes handled by the listener.
A that contains the URI prefixes.
This listener has been closed.
Gets or sets the name of the realm associated with the listener.
A that represents the name of the realm. The default value is
"SECRET AREA".
This listener has been closed.
Gets or sets the SSL configuration used to authenticate the server and
optionally the client for secure connection.
A that represents the configuration used
to authenticate the server and optionally the client for secure connection.
This listener has been closed.
Gets or sets a value indicating whether, when NTLM authentication is used,
the authentication information of first request is used to authenticate
additional requests on the same connection.
This property isn't currently supported and always throws
a .
true if the authentication information of first request is used;
otherwise, false.
Any use of this property.
Gets or sets the delegate called to find the credentials for an identity used to
authenticate a client.
A Func<, > delegate
that references the method used to find the credentials. The default value is a function
that only returns .
This listener has been closed.
Shuts down the listener immediately.
Begins getting an incoming request asynchronously.
This asynchronous operation must be completed by calling the EndGetContext method.
Typically, the method is invoked by the delegate.
An that represents the status of the asynchronous operation.
An delegate that references the method to invoke
when the asynchronous operation completes.
An that represents a user defined object to pass to
the delegate.
This listener has no URI prefix on which listens.
-or-
This listener hasn't been started, or is currently stopped.
This listener has been closed.
Shuts down the listener.
Ends an asynchronous operation to get an incoming request.
This method completes an asynchronous operation started by calling
the BeginGetContext method.
A that represents a request.
An obtained by calling the BeginGetContext method.
is .
wasn't obtained by calling the BeginGetContext method.
This method was already called for the specified .
This listener has been closed.
Gets an incoming request.
This method waits for an incoming request, and returns when a request is received.
A that represents a request.
This listener has no URI prefix on which listens.
-or-
This listener hasn't been started, or is currently stopped.
This listener has been closed.
Starts receiving incoming requests.
This listener has been closed.
Stops receiving incoming requests.
This listener has been closed.
Releases all resources used by the listener.
Provides the access to the HTTP request and response information
used by the .
The HttpListenerContext class cannot be inherited.
Gets the HTTP request information from a client.
A that represents the HTTP request.
Gets the HTTP response information used to send to the client.
A that represents the HTTP response to send.
Gets the client information (identity, authentication, and security roles).
A instance that represents the client information.
Accepts a WebSocket connection request.
A that represents the WebSocket connection
request.
A that represents the subprotocol used in the WebSocket connection.
is empty.
-or-
contains an invalid character.
The exception that is thrown when a gets an error
processing an HTTP request.
Initializes a new instance of the class from
the specified and .
A that contains the serialized object data.
A that specifies the source for the deserialization.
Initializes a new instance of the class.
Initializes a new instance of the class
with the specified .
An that identifies the error.
Initializes a new instance of the class
with the specified and .
An that identifies the error.
A that describes the error.
Gets the error code that identifies the error that occurred.
An that identifies the error.
Provides the collection used to store the URI prefixes for the .
The responds to the request which has a requested URI that
the prefixes most closely match.
Gets the number of prefixes in the collection.
An that represents the number of prefixes.
Gets a value indicating whether the access to the collection is read-only.
Always returns false.
Gets a value indicating whether the access to the collection is synchronized.
Always returns false.
Adds the specified to the collection.
A that represents the URI prefix to add. The prefix must be
a well-formed URI prefix with http or https scheme, and must end with a '/'.
is .
is invalid.
The associated with this collection is closed.
Removes all URI prefixes from the collection.
The associated with this collection is closed.
Returns a value indicating whether the collection contains the specified
.
true if the collection contains ;
otherwise, false.
A that represents the URI prefix to test.
is .
The associated with this collection is closed.
Copies the contents of the collection to the specified .
An that receives the URI prefix strings in the collection.
An that represents the zero-based index in
at which copying begins.
The associated with this collection is closed.
Copies the contents of the collection to the specified array of .
An array of that receives the URI prefix strings in the collection.
An that represents the zero-based index in
at which copying begins.
The associated with this collection is closed.
Gets the enumerator used to iterate through the .
An instance used to iterate
through the collection.
Removes the specified from the collection.
true if is successfully found and removed;
otherwise, false.
A that represents the URI prefix to remove.
is .
The associated with this collection is closed.
Gets the enumerator used to iterate through the .
An instance used to iterate through the collection.
Provides the access to a request to the .
The HttpListenerRequest class cannot be inherited.
Gets the media types which are acceptable for the response.
An array of that contains the media type names in the Accept
request-header, or if the request didn't include an Accept header.
Gets an error code that identifies a problem with the client's certificate.
Always returns 0.
Gets the encoding for the entity body data included in the request.
A that represents the encoding for the entity body data,
or if the request didn't include the information
about the encoding.
Gets the size of the entity body data included in the request.
A that represents the value of the Content-Length entity-header. The
value is a number of bytes in the entity body data. -1 if the size isn't known.
Gets the media type of the entity body included in the request.
A that represents the value of the Content-Type entity-header.
Gets the cookies included in the request.
A that contains the cookies included in the request.
Gets a value indicating whether the request has the entity body.
true if the request has the entity body; otherwise, false.
Gets the HTTP headers used in the request.
A that contains the HTTP headers used in the request.
Gets the HTTP method used in the request.
A that represents the HTTP method used in the request.
Gets a that contains the entity body data included in the request.
A that contains the entity body data included in the request.
Gets a value indicating whether the client that sent the request is authenticated.
true if the client is authenticated; otherwise, false.
Gets a value indicating whether the request is sent from the local computer.
true if the request is sent from the local computer; otherwise, false.
Gets a value indicating whether the HTTP connection is secured using the SSL protocol.
true if the HTTP connection is secured; otherwise, false.
Gets a value indicating whether the request is a WebSocket connection request.
true if the request is a WebSocket connection request; otherwise, false.
Gets a value indicating whether the client requests a persistent connection.
true if the client requests a persistent connection; otherwise, false.
Gets the server endpoint as an IP address and a port number.
A that represents the server endpoint.
Gets the HTTP version used in the request.
A that represents the HTTP version used in the request.
Gets the query string included in the request.
A that contains the query string parameters.
Gets the raw URL (without the scheme, host, and port) requested by the client.
A that represents the raw URL requested by the client.
Gets the client endpoint as an IP address and a port number.
A that represents the client endpoint.
Gets the request identifier of a incoming HTTP request.
A that represents the identifier of a request.
Gets the URL requested by the client.
A that represents the URL requested by the client.
Gets the URL of the resource from which the requested URL was obtained.
A that represents the value of the Referer request-header,
or if the request didn't include an Referer header.
Gets the information about the user agent originating the request.
A that represents the value of the User-Agent request-header.
Gets the server endpoint as an IP address and a port number.
A that represents the server endpoint.
Gets the internet host name and port number (if present) specified by the client.
A that represents the value of the Host request-header.
Gets the natural languages which are preferred for the response.
An array of that contains the natural language names in
the Accept-Language request-header, or if the request
didn't include an Accept-Language header.
Begins getting the client's X.509 v.3 certificate asynchronously.
This asynchronous operation must be completed by calling the
method. Typically, that method is invoked by the
delegate.
An that contains the status of the asynchronous operation.
An delegate that references the method(s) called when the
asynchronous operation completes.
An that contains a user defined object to pass to the
delegate.
This method isn't implemented.
Ends an asynchronous operation to get the client's X.509 v.3 certificate.
This method completes an asynchronous operation started by calling the
method.
A that contains the client's X.509 v.3 certificate.
An obtained by calling the
method.
This method isn't implemented.
Gets the client's X.509 v.3 certificate.
A that contains the client's X.509 v.3 certificate.
This method isn't implemented.
Returns a that represents the current
.
A that represents the current .
Provides the access to a response to a request received by the .
The HttpListenerResponse class cannot be inherited.
Gets or sets the encoding for the entity body data included in the response.
A that represents the encoding for the entity body data,
or if no encoding is specified.
The response has already been sent.
This object is closed.
Gets or sets the size of the entity body data included in the response.
A that represents the value of the Content-Length entity-header.
The value is a number of bytes in the entity body data.
The value specified for a set operation is less than zero.
The response has already been sent.
This object is closed.
Gets or sets the media type of the entity body included in the response.
A that represents the value of the Content-Type entity-header.
The value specified for a set operation is empty.
The value specified for a set operation is .
The response has already been sent.
This object is closed.
Gets or sets the cookies sent with the response.
A that contains the cookies sent with the response.
The response has already been sent.
This object is closed.
Gets or sets the HTTP headers sent to the client.
A that contains the headers sent to the client.
The value specified for a set operation is .
The response has already been sent.
This object is closed.
Gets or sets a value indicating whether the server requests a persistent connection.
true if the server requests a persistent connection; otherwise, false.
The default value is true.
The response has already been sent.
This object is closed.
Gets a to use to write the entity body data.
A to use to write the entity body data.
This object is closed.
Gets or sets the HTTP version used in the response.
A that represents the version used in the response.
The value specified for a set operation doesn't have its Major property set to 1 or
doesn't have its Minor property set to either 0 or 1.
The value specified for a set operation is .
The response has already been sent.
This object is closed.
Gets or sets the URL to which the client is redirected to locate a requested resource.
A that represents the value of the Location response-header.
The value specified for a set operation is empty.
The response has already been sent.
This object is closed.
Gets or sets a value indicating whether the response uses the chunked transfer encoding.
true if the response uses the chunked transfer encoding; otherwise, false.
The response has already been sent.
This object is closed.
Gets or sets the HTTP status code returned to the client.
An that represents the status code for the response to the request.
The default value is .
The response has already been sent.
The value specified for a set operation is invalid. Valid values are between 100 and 999.
This object is closed.
Gets or sets the description of the HTTP status code returned to the client.
A that represents the description of the status code.
The response has already been sent.
This object is closed.
Closes the connection to the client without returning a response.
Adds an HTTP header with the specified and
to the headers for the response.
A that represents the name of the header to add.
A that represents the value of the header to add.
or contains invalid characters.
-or-
is a restricted header name.
is or empty.
The length of is greater than 65,535 characters.
The response has already been sent.
-or-
The header cannot be allowed to add to the current headers.
This object is closed.
Appends the specified to the cookies sent with the response.
A to append.
is .
The response has already been sent.
This object is closed.
Appends a to the specified HTTP header sent with the response.
A that represents the name of the header to append
to.
A that represents the value to append to the header.
or contains invalid characters.
-or-
is a restricted header name.
is or empty.
The length of is greater than 65,535 characters.
The response has already been sent.
-or-
The current headers cannot allow the header to append a value.
This object is closed.
Returns the response to the client and releases the resources used by
this instance.
Returns the response with the specified array of to the client and
releases the resources used by this instance.
An array of that contains the response entity body data.
true if this method blocks execution while flushing the stream to the client;
otherwise, false.
is .
The response has already been sent.
This object is closed.
Copies properties from the specified to this response.
A to copy.
The response has already been sent.
This object is closed.
Configures the response to redirect the client's request to the specified
.
A that represents the URL to redirect the client's request to.
The response has already been sent.
This object is closed.
Adds or updates a in the cookies sent with the response.
A to set.
already exists in the cookies and couldn't be replaced.
is .
The response has already been sent.
This object is closed.
Releases all resources used by the .
Contains the HTTP headers that may be specified in a client request.
The HttpRequestHeader enumeration contains the HTTP request headers defined in
RFC 2616 for the HTTP/1.1 and
RFC 6455 for the WebSocket.
Indicates the Cache-Control header.
Indicates the Connection header.
Indicates the Date header.
Indicates the Keep-Alive header.
Indicates the Pragma header.
Indicates the Trailer header.
Indicates the Transfer-Encoding header.
Indicates the Upgrade header.
Indicates the Via header.
Indicates the Warning header.
Indicates the Allow header.
Indicates the Content-Length header.
Indicates the Content-Type header.
Indicates the Content-Encoding header.
Indicates the Content-Language header.
Indicates the Content-Location header.
Indicates the Content-MD5 header.
Indicates the Content-Range header.
Indicates the Expires header.
Indicates the Last-Modified header.
Indicates the Accept header.
Indicates the Accept-Charset header.
Indicates the Accept-Encoding header.
Indicates the Accept-Language header.
Indicates the Authorization header.
Indicates the Cookie header.
Indicates the Expect header.
Indicates the From header.
Indicates the Host header.
Indicates the If-Match header.
Indicates the If-Modified-Since header.
Indicates the If-None-Match header.
Indicates the If-Range header.
Indicates the If-Unmodified-Since header.
Indicates the Max-Forwards header.
Indicates the Proxy-Authorization header.
Indicates the Referer header.
Indicates the Range header.
Indicates the TE header.
Indicates the Translate header.
Indicates the User-Agent header.
Indicates the Sec-WebSocket-Key header.
Indicates the Sec-WebSocket-Extensions header.
Indicates the Sec-WebSocket-Protocol header.
Indicates the Sec-WebSocket-Version header.
Contains the HTTP headers that can be specified in a server response.
The HttpResponseHeader enumeration contains the HTTP response headers defined in
RFC 2616 for the HTTP/1.1 and
RFC 6455 for the WebSocket.
Indicates the Cache-Control header.
Indicates the Connection header.
Indicates the Date header.
Indicates the Keep-Alive header.
Indicates the Pragma header.
Indicates the Trailer header.
Indicates the Transfer-Encoding header.
Indicates the Upgrade header.
Indicates the Via header.
Indicates the Warning header.
Indicates the Allow header.
Indicates the Content-Length header.
Indicates the Content-Type header.
Indicates the Content-Encoding header.
Indicates the Content-Language header.
Indicates the Content-Location header.
Indicates the Content-MD5 header.
Indicates the Content-Range header.
Indicates the Expires header.
Indicates the Last-Modified header.
Indicates the Accept-Ranges header.
Indicates the Age header.
Indicates the ETag header.
Indicates the Location header.
Indicates the Proxy-Authenticate header.
Indicates the Retry-After header.
Indicates the Server header.
Indicates the Set-Cookie header.
Indicates the Vary header.
Indicates the WWW-Authenticate header.
Indicates the Sec-WebSocket-Extensions header.
Indicates the Sec-WebSocket-Accept header.
Indicates the Sec-WebSocket-Protocol header.
Indicates the Sec-WebSocket-Version header.
Contains the values of the HTTP status codes.
The HttpStatusCode enumeration contains the values of the HTTP status codes defined in
RFC 2616 for the HTTP/1.1.
Equivalent to status code 100.
Indicates that the client should continue with its request.
Equivalent to status code 101.
Indicates that the server is switching the HTTP version or protocol on the connection.
Equivalent to status code 200.
Indicates that the client's request has succeeded.
Equivalent to status code 201.
Indicates that the client's request has been fulfilled and resulted in a new resource being
created.
Equivalent to status code 202.
Indicates that the client's request has been accepted for processing, but the processing
hasn't been completed.
Equivalent to status code 203.
Indicates that the returned metainformation is from a local or a third-party copy instead of
the origin server.
Equivalent to status code 204.
Indicates that the server has fulfilled the client's request but doesn't need to return
an entity-body.
Equivalent to status code 205.
Indicates that the server has fulfilled the client's request, and the user agent should
reset the document view which caused the request to be sent.
Equivalent to status code 206.
Indicates that the server has fulfilled the partial GET request for the resource.
Equivalent to status code 300.
Indicates that the requested resource corresponds to any of multiple representations.
MultipleChoices is a synonym for Ambiguous.
Equivalent to status code 300.
Indicates that the requested resource corresponds to any of multiple representations.
Ambiguous is a synonym for MultipleChoices.
Equivalent to status code 301.
Indicates that the requested resource has been assigned a new permanent URI and
any future references to this resource should use one of the returned URIs.
MovedPermanently is a synonym for Moved.
Equivalent to status code 301.
Indicates that the requested resource has been assigned a new permanent URI and
any future references to this resource should use one of the returned URIs.
Moved is a synonym for MovedPermanently.
Equivalent to status code 302.
Indicates that the requested resource is located temporarily under a different URI.
Found is a synonym for Redirect.
Equivalent to status code 302.
Indicates that the requested resource is located temporarily under a different URI.
Redirect is a synonym for Found.
Equivalent to status code 303.
Indicates that the response to the request can be found under a different URI and
should be retrieved using a GET method on that resource.
SeeOther is a synonym for RedirectMethod.
Equivalent to status code 303.
Indicates that the response to the request can be found under a different URI and
should be retrieved using a GET method on that resource.
RedirectMethod is a synonym for SeeOther.
Equivalent to status code 304.
Indicates that the client has performed a conditional GET request and access is allowed,
but the document hasn't been modified.
Equivalent to status code 305.
Indicates that the requested resource must be accessed through the proxy given by
the Location field.
Equivalent to status code 306.
This status code was used in a previous version of the specification, is no longer used,
and is reserved for future use.
Equivalent to status code 307.
Indicates that the requested resource is located temporarily under a different URI.
TemporaryRedirect is a synonym for RedirectKeepVerb.
Equivalent to status code 307.
Indicates that the requested resource is located temporarily under a different URI.
RedirectKeepVerb is a synonym for TemporaryRedirect.
Equivalent to status code 400.
Indicates that the client's request couldn't be understood by the server due to
malformed syntax.
Equivalent to status code 401.
Indicates that the client's request requires user authentication.
Equivalent to status code 402.
This status code is reserved for future use.
Equivalent to status code 403.
Indicates that the server understood the client's request but is refusing to fulfill it.
Equivalent to status code 404.
Indicates that the server hasn't found anything matching the request URI.
Equivalent to status code 405.
Indicates that the method specified in the request line isn't allowed for the resource
identified by the request URI.
Equivalent to status code 406.
Indicates that the server doesn't have the appropriate resource to respond to the Accept
headers in the client's request.
Equivalent to status code 407.
Indicates that the client must first authenticate itself with the proxy.
Equivalent to status code 408.
Indicates that the client didn't produce a request within the time that the server was
prepared to wait.
Equivalent to status code 409.
Indicates that the client's request couldn't be completed due to a conflict on the server.
Equivalent to status code 410.
Indicates that the requested resource is no longer available at the server and
no forwarding address is known.
Equivalent to status code 411.
Indicates that the server refuses to accept the client's request without a defined
Content-Length.
Equivalent to status code 412.
Indicates that the precondition given in one or more of the request headers evaluated to
false when it was tested on the server.
Equivalent to status code 413.
Indicates that the entity of the client's request is larger than the server is willing or
able to process.
Equivalent to status code 414.
Indicates that the request URI is longer than the server is willing to interpret.
Equivalent to status code 415.
Indicates that the entity of the client's request is in a format not supported by
the requested resource for the requested method.
Equivalent to status code 416.
Indicates that none of the range specifier values in a Range request header overlap
the current extent of the selected resource.
Equivalent to status code 417.
Indicates that the expectation given in an Expect request header couldn't be met by
the server.
Equivalent to status code 500.
Indicates that the server encountered an unexpected condition which prevented it from
fulfilling the client's request.
Equivalent to status code 501.
Indicates that the server doesn't support the functionality required to fulfill the client's
request.
Equivalent to status code 502.
Indicates that a gateway or proxy server received an invalid response from the upstream
server.
Equivalent to status code 503.
Indicates that the server is currently unable to handle the client's request due to
a temporary overloading or maintenance of the server.
Equivalent to status code 504.
Indicates that a gateway or proxy server didn't receive a timely response from the upstream
server or some other auxiliary server.
Equivalent to status code 505.
Indicates that the server doesn't support the HTTP version used in the client's request.
Decodes an HTML-encoded and returns the decoded .
A that represents the decoded string.
A to decode.
Decodes an HTML-encoded and sends the decoded
to the specified .
A to decode.
A that receives the decoded string.
HTML-encodes a and returns the encoded .
A that represents the encoded string.
A to encode.
HTML-encodes a and sends the encoded
to the specified .
A to encode.
A that receives the encoded string.
Provides the HTTP version numbers.
Provides a instance for the HTTP/1.0.
Provides a instance for the HTTP/1.1.
Initializes a new instance of the class.
Provides the credentials for HTTP authentication (Basic/Digest).
Initializes a new instance of the class
with the specified user name and password.
A that represents the user name associated with the
credentials.
A that represents the password for the user name
associated with the credentials.
is or empty.
Initializes a new instance of the class
with the specified user name, password, domain, and roles.
A that represents the user name associated with the
credentials.
A that represents the password for the user name
associated with the credentials.
A that represents the name of the user domain
associated with the credentials.
An array of that contains the role names to which
the user associated with the credentials belongs if any.
is or empty.
Gets the name of the user domain associated with the credentials.
A that represents the name of the user domain
associated with the credentials.
Gets the password for the user name associated with the credentials.
A that represents the password for the user name
associated with the credentials.
Gets the role names to which the user associated with the credentials
belongs.
An array of that contains the role names to which
the user associated with the credentials belongs.
Gets the user name associated with the credentials.
A that represents the user name associated with the
credentials.
Stores the parameters used to configure a instance as a server.
Initializes a new instance of the class with
the specified .
A that represents the certificate used to authenticate
the server.
Initializes a new instance of the class with
the specified ,
, ,
and .
A that represents the certificate used to authenticate
the server.
true if the client must supply a certificate for authentication;
otherwise, false.
The enum value that represents the protocols used for
authentication.
true if the certificate revocation list is checked during authentication;
otherwise, false.
Gets or sets a value indicating whether the client must supply a certificate for
authentication.
true if the client must supply a certificate; otherwise, false.
Gets or sets the callback used to validate the certificate supplied by the client.
If this callback returns true, the client certificate will be valid.
A delegate that references the method
used to validate the client certificate. The default value is a function that only returns
true.
Gets or sets the certificate used to authenticate the server for secure connection.
A that represents the certificate used to authenticate
the server.
Stores the parameters used to configure a instance.
The SslConfiguration class is an abstract class.
Initializes a new instance of the class with
the specified and
.
The enum value that represents the protocols used for
authentication.
true if the certificate revocation list is checked during authentication;
otherwise, false.
Gets or sets the callback used to select a certificate to supply to the remote party.
If this callback returns , no certificate will be supplied.
A delegate that references the method
used to select a certificate. The default value is a function that only returns
.
Gets or sets the callback used to validate the certificate supplied by the remote party.
If this callback returns true, the certificate will be valid.
A delegate that references the method
used to validate the certificate. The default value is a function that only returns
true.
Gets or sets a value indicating whether the certificate revocation list is checked
during authentication.
true if the certificate revocation list is checked; otherwise, false.
Gets or sets the SSL protocols used for authentication.
The enum value that represents the protocols used for
authentication.
Provides a collection of the HTTP headers associated with a request or response.
Initializes a new instance of the class from
the specified and .
A that contains the serialized object data.
A that specifies the source for the deserialization.
is .
An element with the specified name isn't found in .
Initializes a new instance of the class.
Gets all header names in the collection.
An array of that contains all header names in the collection.
Gets the number of headers in the collection.
An that represents the number of headers in the collection.
Gets or sets the specified request in the collection.
A that represents the value of the request .
One of the enum values, represents the request header
to get or set.
is a restricted header.
-or-
contains invalid characters.
The length of is greater than 65,535 characters.
The current instance doesn't allow the request
.
Gets or sets the specified response in the collection.
A that represents the value of the response .
One of the enum values, represents the response header
to get or set.
is a restricted header.
-or-
contains invalid characters.
The length of is greater than 65,535 characters.
The current instance doesn't allow the response
.
Gets a collection of header names in the collection.
A that contains all header names
in the collection.
Adds a header to the collection without checking whether the header is on the restricted
header list.
A that represents the name of the header to add.
A that represents the value of the header to add.
is or empty.
or contains invalid characters.
The length of is greater than 65,535 characters.
The current instance doesn't allow
the .
Adds the specified to the collection.
A that represents the header with the name and value separated by
a colon (':').
is , empty, or the name part of
is empty.
doesn't contain a colon.
-or-
is a restricted header.
-or-
The name or value part of contains invalid characters.
The length of the value part of is greater than 65,535 characters.
The current instance doesn't allow
the .
Adds the specified request with the specified
to the collection.
One of the enum values, represents the request header
to add.
A that represents the value of the header to add.
is a restricted header.
-or-
contains invalid characters.
The length of is greater than 65,535 characters.
The current instance doesn't allow the request
.
Adds the specified response with the specified
to the collection.
One of the enum values, represents the response header
to add.
A that represents the value of the header to add.
is a restricted header.
-or-
contains invalid characters.
The length of is greater than 65,535 characters.
The current instance doesn't allow the response
.
Adds a header with the specified and
to the collection.
A that represents the name of the header to add.
A that represents the value of the header to add.
is or empty.
or contains invalid characters.
-or-
is a restricted header name.
The length of is greater than 65,535 characters.
The current instance doesn't allow the header
.
Removes all headers from the collection.
Get the value of the header at the specified in the collection.
A that receives the value of the header.
An that represents the zero-based index of the header to find.
is out of allowable range of indexes for the collection.
Get the value of the header with the specified in the collection.
A that receives the value of the header if found; otherwise,
.
A that represents the name of the header to find.
Gets the enumerator used to iterate through the collection.
An instance used to iterate through the collection.
Get the name of the header at the specified in the collection.
A that receives the header name.
An that represents the zero-based index of the header to find.
is out of allowable range of indexes for the collection.
Gets an array of header values stored in the specified position
of the collection.
An array of that receives the header values if found; otherwise,
.
An that represents the zero-based index of the header to find.
is out of allowable range of indexes for the collection.
Gets an array of header values stored in the specified .
An array of that receives the header values if found; otherwise,
.
A that represents the name of the header to find.
Populates the specified with the data needed to serialize
the .
A that holds the serialized object data.
A that specifies the destination for the serialization.
is .
Determines whether the specified header can be set for the request.
true if the header is restricted; otherwise, false.
A that represents the name of the header to test.
is or empty.
contains invalid characters.
Determines whether the specified header can be set for the request or the response.
true if the header is restricted; otherwise, false.
A that represents the name of the header to test.
true if does the test for the response; for the request, false.
is or empty.
contains invalid characters.
Implements the interface and raises the deserialization event
when the deserialization is complete.
An that represents the source of the deserialization event.
Removes the specified request from the collection.
One of the enum values, represents the request header
to remove.
is a restricted header.
The current instance doesn't allow the request
.
Removes the specified response from the collection.
One of the enum values, represents the response header
to remove.
is a restricted header.
The current instance doesn't allow the response
.
Removes the specified header from the collection.
A that represents the name of the header to remove.
is or empty.
contains invalid characters.
-or-
is a restricted header name.
The current instance doesn't allow the header
.
Sets the specified request to the specified value.
One of the enum values, represents the request header
to set.
A that represents the value of the request header to set.
is a restricted header.
-or-
contains invalid characters.
The length of is greater than 65,535 characters.
The current instance doesn't allow the request
.
Sets the specified response to the specified value.
One of the enum values, represents the response header
to set.
A that represents the value of the response header to set.
is a restricted header.
-or-
contains invalid characters.
The length of is greater than 65,535 characters.
The current instance doesn't allow the response
.
Sets the specified header to the specified value.
A that represents the name of the header to set.
A that represents the value of the header to set.
is or empty.
or contains invalid characters.
-or-
is a restricted header name.
The length of is greater than 65,535 characters.
The current instance doesn't allow the header
.
Converts the current to an array of .
An array of that receives the converted current
.
Returns a that represents the current
.
A that represents the current .
Populates the specified with the data needed to serialize
the current .
A that holds the serialized object data.
A that specifies the destination for the serialization.
is .
Provides the properties used to access the information in a WebSocket connection request
received by the .
Gets the HTTP cookies included in the request.
A that contains the cookies.
Gets the HTTP headers included in the request.
A that contains the headers.
Gets the value of the Host header included in the request.
A that represents the value of the Host header.
Gets a value indicating whether the client is authenticated.
true if the client is authenticated; otherwise, false.
Gets a value indicating whether the client connected from the local computer.
true if the client connected from the local computer; otherwise, false.
Gets a value indicating whether the WebSocket connection is secured.
true if the connection is secured; otherwise, false.
Gets a value indicating whether the request is a WebSocket connection request.
true if the request is a WebSocket connection request; otherwise, false.
Gets the value of the Origin header included in the request.
A that represents the value of the Origin header.
Gets the query string included in the request.
A that contains the query string parameters.
Gets the URI requested by the client.
A that represents the requested URI.
Gets the value of the Sec-WebSocket-Key header included in the request.
This property provides a part of the information used by the server to prove that it
received a valid WebSocket connection request.
A that represents the value of the Sec-WebSocket-Key header.
Gets the values of the Sec-WebSocket-Protocol header included in the request.
This property represents the subprotocols requested by the client.
An instance that provides
an enumerator which supports the iteration over the values of the Sec-WebSocket-Protocol
header.
Gets the value of the Sec-WebSocket-Version header included in the request.
This property represents the WebSocket protocol version.
A that represents the value of the Sec-WebSocket-Version header.
Gets the server endpoint as an IP address and a port number.
A that represents the server endpoint.
Gets the client information (identity, authentication, and security roles).
A instance that represents the client information.
Gets the client endpoint as an IP address and a port number.
A that represents the client endpoint.
Gets the instance used for two-way communication
between client and server.
A .
Returns a that represents the current
.
A that represents the current
.
Provides the properties used to access the information in a WebSocket connection request
received by the .
Gets the HTTP cookies included in the request.
A that contains the cookies.
Gets the HTTP headers included in the request.
A that contains the headers.
Gets the value of the Host header included in the request.
A that represents the value of the Host header.
Gets a value indicating whether the client is authenticated.
true if the client is authenticated; otherwise, false.
Gets a value indicating whether the client connected from the local computer.
true if the client connected from the local computer; otherwise, false.
Gets a value indicating whether the WebSocket connection is secured.
true if the connection is secured; otherwise, false.
Gets a value indicating whether the request is a WebSocket connection request.
true if the request is a WebSocket connection request; otherwise, false.
Gets the value of the Origin header included in the request.
A that represents the value of the Origin header.
Gets the query string included in the request.
A that contains the query string parameters.
Gets the URI requested by the client.
A that represents the requested URI.
Gets the value of the Sec-WebSocket-Key header included in the request.
This property provides a part of the information used by the server to prove that it
received a valid WebSocket connection request.
A that represents the value of the Sec-WebSocket-Key header.
Gets the values of the Sec-WebSocket-Protocol header included in the request.
This property represents the subprotocols requested by the client.
An instance that provides
an enumerator which supports the iteration over the values of the Sec-WebSocket-Protocol
header.
Gets the value of the Sec-WebSocket-Version header included in the request.
This property represents the WebSocket protocol version.
A that represents the value of the Sec-WebSocket-Version header.
Gets the server endpoint as an IP address and a port number.
A that represents the server endpoint.
Gets the client information (identity, authentication, and security roles).
A instance that represents the client information.
Gets the client endpoint as an IP address and a port number.
A that represents the client endpoint.
Gets the instance used for two-way communication
between client and server.
A .
Returns a that represents the current
.
A that represents the current
.
Exposes the properties used to access the information in a WebSocket connection request.
The WebSocketContext class is an abstract class.
Initializes a new instance of the class.
Gets the HTTP cookies included in the request.
A that contains the cookies.
Gets the HTTP headers included in the request.
A that contains the headers.
Gets the value of the Host header included in the request.
A that represents the value of the Host header.
Gets a value indicating whether the client is authenticated.
true if the client is authenticated; otherwise, false.
Gets a value indicating whether the client connected from the local computer.
true if the client connected from the local computer; otherwise, false.
Gets a value indicating whether the WebSocket connection is secured.
true if the connection is secured; otherwise, false.
Gets a value indicating whether the request is a WebSocket connection request.
true if the request is a WebSocket connection request; otherwise, false.
Gets the value of the Origin header included in the request.
A that represents the value of the Origin header.
Gets the query string included in the request.
A that contains the query string parameters.
Gets the URI requested by the client.
A that represents the requested URI.
Gets the value of the Sec-WebSocket-Key header included in the request.
This property provides a part of the information used by the server to prove that it
received a valid WebSocket connection request.
A that represents the value of the Sec-WebSocket-Key header.
Gets the values of the Sec-WebSocket-Protocol header included in the request.
This property represents the subprotocols requested by the client.
An instance that provides
an enumerator which supports the iteration over the values of the Sec-WebSocket-Protocol
header.
Gets the value of the Sec-WebSocket-Version header included in the request.
This property represents the WebSocket protocol version.
A that represents the value of the Sec-WebSocket-Version header.
Gets the server endpoint as an IP address and a port number.
A that represents the server endpoint.
Gets the client information (identity, authentication, and security roles).
A instance that represents the client information.
Gets the client endpoint as an IP address and a port number.
A that represents the client endpoint.
Gets the instance used for two-way communication
between client and server.
A .
Contains the event data associated with an HTTP request event that
the emits.
An HTTP request event occurs when the receives an HTTP request.
If you would like to get the request data, you should access
the property.
And if you would like to get the data used to return a response, you should access
the property.
Gets the that represents the HTTP request sent from
a client.
A that represents the request.
Gets the used to return an HTTP response to the client.
A used to return a response.
Provides a simple HTTP server that allows to accept the WebSocket connection requests.
The HttpServer class can provide multiple WebSocket services.
Initializes a new instance of the class.
An instance initialized by this constructor listens for the incoming requests on port 80.
Initializes a new instance of the class with the specified
.
An instance initialized by this constructor listens for the incoming requests
on .
If is 443, that instance provides a secure connection.
An that represents the port number on which to listen.
isn't between 1 and 65535.
Initializes a new instance of the class with the specified
and .
An instance initialized by this constructor listens for the incoming requests
on .
An that represents the port number on which to listen.
A that indicates providing a secure connection or not.
(true indicates providing a secure connection.)
Pair of and is invalid.
isn't between 1 and 65535.
Gets or sets the scheme used to authenticate the clients.
One of the enum values,
indicates the scheme used to authenticate the clients. The default value is
.
Gets a value indicating whether the server has started.
true if the server has started; otherwise, false.
Gets a value indicating whether the server provides a secure connection.
true if the server provides a secure connection; otherwise, false.
Gets or sets a value indicating whether the server cleans up the inactive sessions
in the WebSocket services periodically.
true if the server cleans up the inactive sessions every 60 seconds;
otherwise, false. The default value is true.
Gets the logging functions.
The default logging level is . If you would like to change it,
you should set the Log.Level property to any of the enum
values.
A that provides the logging functions.
Gets the port on which to listen for incoming requests.
An that represents the port number on which to listen.
Gets or sets the name of the realm associated with the server.
A that represents the name of the realm.
The default value is "SECRET AREA".
Gets or sets a value indicating whether the server is allowed to be bound to an address
that is already in use.
If you would like to resolve to wait for socket in TIME_WAIT state, you should set
this property to true.
true if the server is allowed to be bound to an address that is already in use;
otherwise, false. The default value is false.
Gets or sets the document root path of the server.
A that represents the document root path of the server.
The default value is "./Public".
Gets or sets the SSL configuration used to authenticate the server and
optionally the client for secure connection.
A that represents the configuration used
to authenticate the server and optionally the client for secure connection.
Gets or sets the delegate called to find the credentials for an identity used to
authenticate a client.
A Func<, > delegate that
references the method(s) used to find the credentials. The default value is a function
that only returns .
Gets or sets the wait time for the response to the WebSocket Ping or Close.
A that represents the wait time. The default value is
the same as 1 second.
Gets the access to the WebSocket services provided by the server.
A that manages the WebSocket services.
Occurs when the server receives an HTTP CONNECT request.
Occurs when the server receives an HTTP DELETE request.
Occurs when the server receives an HTTP GET request.
Occurs when the server receives an HTTP HEAD request.
Occurs when the server receives an HTTP OPTIONS request.
Occurs when the server receives an HTTP PATCH request.
Occurs when the server receives an HTTP POST request.
Occurs when the server receives an HTTP PUT request.
Occurs when the server receives an HTTP TRACE request.
Adds a WebSocket service with the specified behavior and .
This method converts to URL-decoded string,
and removes '/' from tail end of .
A that represents the absolute path to the service to add.
The type of the behavior of the service to add. The TBehaviorWithNew must inherit
the class, and must have a public parameterless
constructor.
Adds the WebSocket service with the specified behavior, ,
and .
This method converts to URL-decoded string,
and removes '/' from tail end of .
returns an initialized specified typed
instance.
A that represents the absolute path to the service to add.
A Func<T> delegate that references the method used to initialize a new specified
typed instance (a new
instance).
The type of the behavior of the service to add. The TBehavior must inherit
the class.
Gets the contents of the file with the specified .
An array of that receives the contents of the file,
or if it doesn't exist.
A that represents the virtual path to the file to find.
Removes the WebSocket service with the specified .
This method converts to URL-decoded string,
and removes '/' from tail end of .
true if the service is successfully found and removed; otherwise, false.
A that represents the absolute path to the service to find.
Starts receiving the HTTP requests.
Stops receiving the HTTP requests.
Stops receiving the HTTP requests with the specified and
used to stop the WebSocket services.
A that represents the status code indicating the reason for the stop.
A that represents the reason for the stop.
Stops receiving the HTTP requests with the specified and
used to stop the WebSocket services.
One of the enum values, represents the status code
indicating the reason for the stop.
A that represents the reason for the stop.
Exposes the properties used to access the information in a session in a WebSocket service.
Gets the information in the connection request to the WebSocket service.
A that provides the access to the connection request.
Gets the unique ID of the session.
A that represents the unique ID of the session.
Gets the WebSocket subprotocol used in the session.
A that represents the subprotocol if any.
Gets the time that the session has started.
A that represents the time that the session has started.
Gets the state of the used in the session.
One of the enum values, indicates the state of
the used in the session.
Exposes the methods and properties used to define the behavior of a WebSocket service
provided by the or .
The WebSocketBehavior class is an abstract class.
Initializes a new instance of the class.
Gets the logging functions.
A that provides the logging functions, or
if the WebSocket connection isn't established.
Gets the access to the sessions in the WebSocket service.
A that provides the access to the sessions,
or if the WebSocket connection isn't established.
Gets the information in a connection request to the WebSocket service.
A that provides the access to the connection request,
or if the WebSocket connection isn't established.
Gets or sets the delegate called to validate the HTTP cookies included in
a connection request to the WebSocket service.
The delegate is called when the used in the session validates
the connection request.
A Func<CookieCollection, CookieCollection, bool> delegate that references
the method(s) used to validate the cookies. 1st passed to
this delegate contains the cookies to validate if any. 2nd
passed to this delegate receives the cookies to send to the client.
This delegate should return true if the cookies are valid.
The default value is , and it does nothing to validate.
Gets the unique ID of a session.
A that represents the unique ID of the session,
or if the WebSocket connection isn't established.
Gets or sets a value indicating whether the WebSocket service ignores
the Sec-WebSocket-Extensions header included in a connection request.
true if the WebSocket service ignores the extensions; otherwise, false.
The default value is false.
Gets or sets the delegate called to validate the Origin header included in
a connection request to the WebSocket service.
The delegate is called when the used in the session validates
the connection request.
A Func<string, bool> delegate that references the method(s) used to validate
the origin header. A passed to this delegate represents the value of
the origin header to validate if any.
This delegate should return true if the origin header is valid.
The default value is , and it does nothing to validate.
Gets or sets the WebSocket subprotocol used in the WebSocket service.
Set operation of this property is available before the WebSocket connection has been
established.
A that represents the subprotocol if any.
The default value is .
The value to set must be a token defined in
RFC 2616.
Gets the time that a session has started.
A that represents the time that the session has started,
or if the WebSocket connection isn't established.
Gets the state of the used in a session.
One of the enum values, indicates the state of
the used in the session.
Calls the method with the specified and
.
This method doesn't call the method if is
or empty.
A that represents the error message.
An instance that represents the cause of the error if any.
Called when the WebSocket connection used in a session has been closed.
A that represents the event data passed to
a event.
Called when the used in a session gets an error.
A that represents the event data passed to
a event.
Called when the used in a session receives a message.
A that represents the event data passed to
a event.
Called when the WebSocket connection used in a session has been established.
Sends a binary to the client on a session.
This method is available after the WebSocket connection has been established.
An array of that represents the binary data to send.
Sends the specified as a binary data to the client on a session.
This method is available after the WebSocket connection has been established.
A that represents the file to send.
Sends a text to the client on a session.
This method is available after the WebSocket connection has been established.
A that represents the text data to send.
Sends a binary asynchronously to the client on a session.
This method is available after the WebSocket connection has been established.
This method doesn't wait for the send to be complete.
An array of that represents the binary data to send.
An Action<bool> delegate that references the method(s) called when
the send is complete. A passed to this delegate is true
if the send is complete successfully.
Sends the specified as a binary data asynchronously
to the client on a session.
This method is available after the WebSocket connection has been established.
This method doesn't wait for the send to be complete.
A that represents the file to send.
An Action<bool> delegate that references the method(s) called when
the send is complete. A passed to this delegate is true
if the send is complete successfully.
Sends a text asynchronously to the client on a session.
This method is available after the WebSocket connection has been established.
This method doesn't wait for the send to be complete.
A that represents the text data to send.
An Action<bool> delegate that references the method(s) called when
the send is complete. A passed to this delegate is true
if the send is complete successfully.
Sends a binary data from the specified asynchronously
to the client on a session.
This method is available after the WebSocket connection has been established.
This method doesn't wait for the send to be complete.
A from which contains the binary data to send.
An that represents the number of bytes to send.
An Action<bool> delegate that references the method(s) called when
the send is complete. A passed to this delegate is true
if the send is complete successfully.
Provides a WebSocket protocol server.
The WebSocketServer class can provide multiple WebSocket services.
Initializes a new instance of the class.
An instance initialized by this constructor listens for the incoming connection requests
on port 80.
Initializes a new instance of the class with the specified
.
An instance initialized by this constructor listens for the incoming connection requests
on .
If is 443, that instance provides a secure connection.
An that represents the port number on which to listen.
isn't between 1 and 65535.
Initializes a new instance of the class with the specified
WebSocket URL.
An instance initialized by this constructor listens for the incoming connection requests
on the port in .
If doesn't include a port, either port 80 or 443 is used on which
to listen. It's determined by the scheme (ws or wss) in .
(Port 80 if the scheme is ws.)
A that represents the WebSocket URL of the server.
is invalid.
is .
Initializes a new instance of the class with the specified
and .
An instance initialized by this constructor listens for the incoming connection requests
on .
An that represents the port number on which to listen.
A that indicates providing a secure connection or not.
(true indicates providing a secure connection.)
Pair of and is invalid.
isn't between 1 and 65535.
Initializes a new instance of the class with the specified
and .
An instance initialized by this constructor listens for the incoming connection requests
on .
If is 443, that instance provides a secure connection.
A that represents the local IP address of the server.
An that represents the port number on which to listen.
isn't a local IP address.
is .
isn't between 1 and 65535.
Initializes a new instance of the class with the specified
, , and .
An instance initialized by this constructor listens for the incoming connection requests
on .
A that represents the local IP address of the server.
An that represents the port number on which to listen.
A that indicates providing a secure connection or not.
(true indicates providing a secure connection.)
isn't a local IP address.
-or-
Pair of and is invalid.
is .
isn't between 1 and 65535.
Gets the local IP address of the server.
A that represents the local IP address of the server.
Gets or sets the scheme used to authenticate the clients.
One of the enum values,
indicates the scheme used to authenticate the clients. The default value is
.
Gets a value indicating whether the server has started.
true if the server has started; otherwise, false.
Gets a value indicating whether the server provides a secure connection.
true if the server provides a secure connection; otherwise, false.
Gets or sets a value indicating whether the server cleans up the inactive sessions
periodically.
true if the server cleans up the inactive sessions every 60 seconds;
otherwise, false. The default value is true.
Gets the logging functions.
The default logging level is . If you would like to change it,
you should set the Log.Level property to any of the enum
values.
A that provides the logging functions.
Gets the port on which to listen for incoming connection requests.
An that represents the port number on which to listen.
Gets or sets the name of the realm associated with the server.
A that represents the name of the realm.
The default value is "SECRET AREA".
Gets or sets a value indicating whether the server is allowed to be bound to an address
that is already in use.
If you would like to resolve to wait for socket in TIME_WAIT state, you should set
this property to true.
true if the server is allowed to be bound to an address that is already in use;
otherwise, false. The default value is false.
Gets or sets the SSL configuration used to authenticate the server and
optionally the client for secure connection.
A that represents the configuration used
to authenticate the server and optionally the client for secure connection.
Gets or sets the delegate called to find the credentials for an identity used to
authenticate a client.
A Func<, > delegate that
references the method(s) used to find the credentials. The default value is a function
that only returns .
Gets or sets the wait time for the response to the WebSocket Ping or Close.
A that represents the wait time. The default value is
the same as 1 second.
Gets the access to the WebSocket services provided by the server.
A that manages the WebSocket services.
Adds a WebSocket service with the specified behavior and .
This method converts to URL-decoded string,
and removes '/' from tail end of .
A that represents the absolute path to the service to add.
The type of the behavior of the service to add. The TBehaviorWithNew must inherit
the class, and must have a public parameterless
constructor.
Adds a WebSocket service with the specified behavior, ,
and .
This method converts to URL-decoded string,
and removes '/' from tail end of .
returns an initialized specified typed
instance.
A that represents the absolute path to the service to add.
A Func<T> delegate that references the method used to initialize a new specified
typed instance (a new
instance).
The type of the behavior of the service to add. The TBehavior must inherit
the class.
Removes the WebSocket service with the specified .
This method converts to URL-decoded string,
and removes '/' from tail end of .
true if the service is successfully found and removed; otherwise, false.
A that represents the absolute path to the service to find.
Starts receiving the WebSocket connection requests.
Stops receiving the WebSocket connection requests.
Stops receiving the WebSocket connection requests with the specified
and .
A that represents the status code indicating the reason for the stop.
A that represents the reason for the stop.
Stops receiving the WebSocket connection requests with the specified
and .
One of the enum values, represents the status code
indicating the reason for the stop.
A that represents the reason for the stop.
Exposes the methods and properties used to access the information in a WebSocket service
provided by the or .
The WebSocketServiceHost class is an abstract class.
Initializes a new instance of the class.
Gets or sets a value indicating whether the WebSocket service cleans up
the inactive sessions periodically.
true if the service cleans up the inactive sessions periodically;
otherwise, false.
Gets the path to the WebSocket service.
A that represents the absolute path to the service.
Gets the access to the sessions in the WebSocket service.
A that manages the sessions in the service.
Gets the of the behavior of the WebSocket service.
A that represents the type of the behavior of the service.
Gets or sets the wait time for the response to the WebSocket Ping or Close.
A that represents the wait time. The default value is
the same as 1 second.
Creates a new session in the WebSocket service.
A instance that represents a new session.
Manages the WebSocket services provided by the or
.
Gets the number of the WebSocket services.
An that represents the number of the services.
Gets the host instances for the Websocket services.
An IEnumerable<WebSocketServiceHost> instance that provides an enumerator
which supports the iteration over the collection of the host instances for the services.
Gets the WebSocket service host with the specified .
A instance that provides the access to
the information in the service, or if it's not found.
A that represents the absolute path to the service to find.
Gets a value indicating whether the manager cleans up the inactive sessions
in the WebSocket services periodically.
true if the manager cleans up the inactive sessions every 60 seconds;
otherwise, false.
Gets the paths for the WebSocket services.
An IEnumerable<string> instance that provides an enumerator which supports
the iteration over the collection of the paths for the services.
Gets the total number of the sessions in the WebSocket services.
An that represents the total number of the sessions in the services.
Gets the wait time for the response to the WebSocket Ping or Close.
A that represents the wait time.
Broadcasts a binary to every client in the WebSocket services.
An array of that represents the binary data to broadcast.
Broadcasts a text to every client in the WebSocket services.
A that represents the text data to broadcast.
Broadcasts a binary asynchronously to every client
in the WebSocket services.
This method doesn't wait for the broadcast to be complete.
An array of that represents the binary data to broadcast.
An delegate that references the method(s) called when
the broadcast is complete.
Broadcasts a text asynchronously to every client
in the WebSocket services.
This method doesn't wait for the broadcast to be complete.
A that represents the text data to broadcast.
An delegate that references the method(s) called when
the broadcast is complete.
Broadcasts a binary data from the specified asynchronously
to every client in the WebSocket services.
This method doesn't wait for the broadcast to be complete.
A from which contains the binary data to broadcast.
An that represents the number of bytes to broadcast.
An delegate that references the method(s) called when
the broadcast is complete.
Sends a Ping to every client in the WebSocket services.
A Dictionary<string, Dictionary<string, bool>> that contains
a collection of pairs of a service path and a collection of pairs of a session ID
and a value indicating whether the manager received a Pong from each client in a time,
or if this method isn't available.
Sends a Ping with the specified to every client
in the WebSocket services.
A Dictionary<string, Dictionary<string, bool>> that contains
a collection of pairs of a service path and a collection of pairs of a session ID
and a value indicating whether the manager received a Pong from each client in a time,
or if this method isn't available or
is invalid.
A that represents the message to send.
Tries to get the WebSocket service host with the specified .
true if the service is successfully found; otherwise, false.
A that represents the absolute path to the service to find.
When this method returns, a instance that provides
the access to the information in the service, or if it's not found.
This parameter is passed uninitialized.
Manages the sessions in a Websocket service.
Gets the IDs for the active sessions in the Websocket service.
An IEnumerable<string> instance that provides an enumerator which
supports the iteration over the collection of the IDs for the active sessions.
Gets the number of the sessions in the Websocket service.
An that represents the number of the sessions.
Gets the IDs for the sessions in the Websocket service.
An IEnumerable<string> instance that provides an enumerator which
supports the iteration over the collection of the IDs for the sessions.
Gets the IDs for the inactive sessions in the Websocket service.
An IEnumerable<string> instance that provides an enumerator which
supports the iteration over the collection of the IDs for the inactive sessions.
Gets the session with the specified .
A instance that provides the access to
the information in the session, or if it's not found.
A that represents the ID of the session to find.
Gets a value indicating whether the manager cleans up the inactive sessions in
the WebSocket service periodically.
true if the manager cleans up the inactive sessions every 60 seconds;
otherwise, false.
Gets the sessions in the Websocket service.
An IEnumerable<IWebSocketSession> instance that provides an enumerator
which supports the iteration over the collection of the sessions in the service.
Gets the wait time for the response to the WebSocket Ping or Close.
A that represents the wait time.
Sends binary to every client in the WebSocket service.
An array of that represents the binary data to send.
Sends text to every client in the WebSocket service.
A that represents the text data to send.
Sends binary asynchronously to every client in
the WebSocket service.
This method doesn't wait for the send to be complete.
An array of that represents the binary data to send.
An delegate that references the method(s) called when
the send is complete.
Sends text asynchronously to every client in
the WebSocket service.
This method doesn't wait for the send to be complete.
A that represents the text data to send.
An delegate that references the method(s) called when
the send is complete.
Sends binary data from the specified asynchronously to
every client in the WebSocket service.
This method doesn't wait for the send to be complete.
A from which contains the binary data to send.
An that represents the number of bytes to send.
An delegate that references the method(s) called when
the send is complete.
Sends a Ping to every client in the WebSocket service.
A Dictionary<string, bool> that contains a collection of pairs of
a session ID and a value indicating whether the manager received a Pong from
each client in a time.
Sends a Ping with the specified to every client in
the WebSocket service.
A Dictionary<string, bool> that contains a collection of pairs of
a session ID and a value indicating whether the manager received a Pong from
each client in a time.
A that represents the message to send.
Closes the session with the specified .
A that represents the ID of the session to close.
Closes the session with the specified , ,
and .
A that represents the ID of the session to close.
A that represents the status code indicating the reason for the close.
A that represents the reason for the close.
Closes the session with the specified , ,
and .
A that represents the ID of the session to close.
One of the enum values, represents the status code
indicating the reason for the close.
A that represents the reason for the close.
Sends a Ping to the client on the session with the specified .
true if the manager receives a Pong from the client in a time;
otherwise, false.
A that represents the ID of the session to find.
Sends a Ping with the specified to the client on
the session with the specified .
true if the manager receives a Pong from the client in a time;
otherwise, false.
A that represents the message to send.
A that represents the ID of the session to find.
Sends binary to the client on the session with
the specified .
An array of that represents the binary data to send.
A that represents the ID of the session to find.
Sends text to the client on the session with
the specified .
A that represents the text data to send.
A that represents the ID of the session to find.
Sends binary asynchronously to the client on
the session with the specified .
This method doesn't wait for the send to be complete.
An array of that represents the binary data to send.
A that represents the ID of the session to find.
An Action<bool> delegate that references the method(s) called when
the send is complete. A passed to this delegate is true
if the send is complete successfully.
Sends text asynchronously to the client on
the session with the specified .
This method doesn't wait for the send to be complete.
A that represents the text data to send.
A that represents the ID of the session to find.
An Action<bool> delegate that references the method(s) called when
the send is complete. A passed to this delegate is true
if the send is complete successfully.
Sends binary data from the specified asynchronously to
the client on the session with the specified .
This method doesn't wait for the send to be complete.
A from which contains the binary data to send.
An that represents the number of bytes to send.
A that represents the ID of the session to find.
An Action<bool> delegate that references the method(s) called when
the send is complete. A passed to this delegate is true
if the send is complete successfully.
Cleans up the inactive sessions in the WebSocket service.
Tries to get the session with the specified .
true if the session is successfully found; otherwise, false.
A that represents the ID of the session to find.
When this method returns, a instance that
provides the access to the information in the session, or
if it's not found. This parameter is passed uninitialized.