This project is read-only.

Extend server's configuration

When you implement your socket server by SuperSocket, it is unavoidable to define some parameters in configuration file.The SuperSocket provides a very easy way to store the parameters in your configuration file and then read and use them in AppServer.

Please take a look at the following configuration code:
<server name="FlashPolicyServer"
            ip="Any" port="843"

In the above configuration file, the last property of the server node, policyFile="Policy\flash.xml" is not a SuperSocket built-in configuration property, but an extended attribute. And this extended attribute can be read in the Setup method of your AppServer. Please take a look at the following sample code:
public override bool Setup(IRootConfig rootConfig, IServerConfig config, ISocketServerFactory socketServerFactory, ICustomProtocol<BinaryCommandInfo> protocol)
    if (!base.Setup(rootConfig, config, socketServerFactory, protocol))
        return false;

    m_PolicyFile = config.Options.GetValue("policyFile");

    if (string.IsNullOrEmpty(m_PolicyFile))
        Logger.LogError("Configuration option policyFile is required!");
        return false;

    if (!File.Exists(m_PolicyFile))
        Logger.LogError("The specified policyFile doesn't exist! " + m_PolicyFile);
        return false;

    return true;

Last edited Jun 27, 2011 at 3:43 PM by kerryjiang, version 4


No comments yet.