Click or drag to resize

SmartFoxLoadConfig Method (String, Boolean)

Loads the client configuration file.

Namespace:  Sfs2X
Assembly:  SmartFox2X (in SmartFox2X.dll) Version: (1.7.11)
public void LoadConfig(
	string filePath,
	bool connectOnSuccess


Type: SystemString
(default: sfs-config.xml) Filename of the external XML configuration, including its path relative to the folder of the application file.
Type: SystemBoolean
(default: true) A flag indicating if the connection to SmartFoxServer must be attempted upon configuration loading completion.
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 Connect(String, Int32) method is automatically called by the API, otherwise the CONFIG_LOAD_SUCCESS event is dispatched. In case of loading error, the CONFIG_LOAD_FAILURE event id fired.

The external xml configuration file has the following structure:


    <!-- required -->

    <!-- required -->





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 Also