SmartFoxServer Silverlight API
LoadConfig Method (configFile, autoConnect)
Namespaces ► SmartFoxClientAPI ► SmartFoxClient ► LoadConfig(String, Boolean)
Load a client configuration file.
The SmartFoxClient instance can be configured through an external xml configuration file loaded at run-time.
By default, the LoadConfig method loads a file named "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 SFSEvent..::.OnConfigLoadSuccessDelegate event is dispatched.
In case of loading error, the SFSEvent..::.OnConfigLoadFailureDelegate event id fired.
Declaration Syntax

C# | Visual Basic | Visual C++

    public void LoadConfig(
    	string configFile,
    	bool autoConnect
    )

    Public Sub LoadConfig ( _
    	configFile As String, _
    	autoConnect As Boolean _
    )

    public:
    void LoadConfig(
    	String^ configFile,
    	bool autoConnect
    )

Parameters

configFile (String)
  external xml configuration file name (optional).

autoConnect (Boolean)
  a boolean flag indicating if the connection to SmartFoxServer must be attempted upon configuration loading completion (optional).

Remarks

Sends:
SFSEvent..::.OnConfigLoadSuccessDelegate
SFSEvent..::.OnConfigLoadFailureDelegate

NOTE:
the SmartFoxClient configuration file (client-side) should not be confused with the SmartFoxServer configuration file (server-side).

Usage Note:
The external xml configuration file has the following structure; ip, port and zone parameters are mandatory, all other parameters are optional.

CopyC#

    <SmartFoxClient><ip>127.0.0.1</ip><port>9339</port><zone>simpleChat</zone><debug>true</debug><blueBoxIpAddress>127.0.0.1</blueBoxIpAddress><blueBoxPort>9339</blueBoxPort><smartConnect>true</smartConnect><httpPort>8080</httpPort><httpPollSpeed>750</httpPollSpeed><rawProtocolSeparator>%</rawProtocolSeparator></SmartFoxClient>

Since:
SmartFoxServer Pro v1.6.0

Version:
SmartFoxServer Pro

Examples
The following example shows how to load an external configuration file.
CopyC#

    SFSEvent.onConfigLoadSuccess += OnConfigLoadSuccess;
    SFSEvent.onConfigLoadFailure += OnConfigLoadFailure;

    smartFox.LoadConfig("testEnvironmentConfig.xml", false);

    public void OnConfigLoadSuccess()
    {
        Debug.WriteLine("Config file loaded, now connecting...");
        smartFox.Connect(smartFox.ipAddress, smartFox.port);
    }

    public void OnConfigLoadFailure(string message)
    {
        Debug.WriteLine("Failed loading config file: " + message);
    }

See Also
ipAddress
port
defaultZone
debug
blueBoxIpAddress
blueBoxPort
httpPort
GetHttpPollSpeed()()()
GetRawProtocolSeparator()()()
SFSEvent..::.OnConfigLoadSuccessDelegate
SFSEvent..::.OnConfigLoadFailureDelegate
smartConnect

Assembly: SmartFoxClientAPI_Silverlight (Module: SmartFoxClientAPI_Silverlight) Version: 1.0.0.0 (1.0.0.0)