Establishes a connection between the client and a SmartFoxServer 2X instance using a configuration object.

Namespace: Sfs2X
Assembly: SmartFox2X (in SmartFox2X.dll) Version: 1.7.0.0 (1.7.0)

Syntax

C#
public void Connect(
	ConfigData cfg
)

Parameters

cfg
Type: Sfs2X.Util..::..ConfigData
The client configuration object.

Remarks

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.

Examples

The following example connects to a local SmartFoxServer 2X instance:
 Copy imageCopy
ConfigData cfg = new ConfigData();
cfg.Host = "127.0.0.1";
cfg.Port = 9933;
cfg.Zone = "BasicExamples";
sfs.Connect(cfg);

Exceptions

ExceptionCondition
System..::..ArgumentExceptionIf an invalid host/address or port is passed, and it can't be found in the loaded settings.

See Also