Sends a command to the server-side Extension attached to the Zone or to a Room.

Namespace: Sfs2X.Requests
Assembly: SmartFox2X (in SmartFox2X.dll) Version: 1.7.3.0 (1.7.3)

Syntax

C#
public class ExtensionRequest : BaseRequest

Remarks

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 EXTENSION_RESPONSE 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.

Examples

The following example sends a command to the Zone Extension; it also handles responses coming from the Extension by implementing the EXTENSION_RESPONSE event listener (the same command name is used in both the request and the response):
 Copy imageCopy
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
    }
}

Inheritance Hierarchy

System..::..Object
  BaseRequest
    Sfs2X.Requests..::..ExtensionRequest

See Also