Class SFS2X.Requests.System.ExtensionRequest

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

Class Summary
Constructor Attributes Constructor Name and Description
Creates a new ExtensionRequest instance.

Class Detail

SFS2X.Requests.System.ExtensionRequest(extCmd, params, room)
Creates a new ExtensionRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.

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

function someMethod()
	sfs.addEventListener(SFS2X.SFSEvent.EXTENSION_RESPONSE, onExtensionResponse, this);
	// Send two integers to the Zone extension and get their sum in return
	var params = {};
	params.n1 = 26;
	params.n2 = 16;
	sfs.send(new SFS2X.Requests.System.ExtensionRequest("add", params));

function onExtensionResponse(evtParams)
	if (evtParams.cmd == "add")
		var responseParams = evtParams.params;
		// We expect a number called "sum"
		console.log("The sum is: " + responseParams.sum);
{String} extCmd
The name of the command which identifies an action that should be executed by the server-side Extension.
{Object} params Optional, Default: null
An object containing custom data to be sent to the Extension. Can be null if no data needs to be sent.
{SFSRoom} room Optional, Default: null
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.
See also: