How to pass SuperWebSocket configuration parameters to appServer.Setup method?

Sep 22, 2014 at 3:39 PM
Edited Sep 22, 2014 at 3:54 PM
Hello!
I want to define some SuperWebSocket parameters in the app.config file. I want to use only the standard parameters defined in "Server Configuration" section of "SuperSocket Basic Configuration" page (http://docs.supersocket.net/v1-6/SuperSocket-Basic-Configuration)

My app.config file is below:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <superSocket>
    <servers>
      <server name="SuperWebSocket"
              serverTypeName="SuperWebSocket"
              ip="Any"
              port="2011"
              receiveBufferSize = "1048576"
              maxRequestLength = "1048576">
      </server>
    </servers>
    <serverTypes>
      <add name="SuperWebSocket"
           type="SuperWebSocket.WebSocketServer, SuperWebSocket" />
    </serverTypes>
  </superSocket>
</configuration>
  1. What should be the code to pass the defined parameters to the [WebSocketServer].Setup method?
  2. Is it possible that server will use all defined parameters without extracting them one-by-one in code? I found the example of such operation for the older version of SuperSocket, but it does not work for SuperSocket 1.6+ (SocketServerManager does not exist). What should be the updated code?
        var serverConfig = ConfigurationManager.GetSection("superSocket") as SocketServiceConfig;
        if (!SocketServerManager.Initialize(serverConfig))
            Assert.Fail("SocketServerManager was not able to initialize");
    
Thank you!
Coordinator
Sep 22, 2014 at 4:59 PM
There is a document talking about that:
http://docs.supersocket.net/v1-6/en-US/Extend-Server-Configuration


BTW, we don't have SocketServerManager now, follow the samples to use bootstrap.
Sep 23, 2014 at 8:27 AM
Hello,
Thank you for your answer.
In your referenced page I found the following code to extract the specific value from IServerConfig config :
public class YourAppServer : AppServer
{
  private string m_PolicyFile;
  protected override bool Setup(IRootConfig rootConfig, IServerConfig config)
  {  
    m_PolicyFile = config.Options.GetValue("policyFile");
    if (string.IsNullOrEmpty(m_PolicyFile))
    {
        if(Logger.IsErrorEnabled)
          Logger.Error("Configuration option policyFile is required!");
        return false;
    }
    return true;
  }
}
But how can I create the objects to pass to the method arguments (IRootConfig rootConfig, IServerConfig config) ?
Thanks.
Oct 20, 2014 at 4:48 AM
Hi All,

Can somebody post the example regarding how to migrate from SocketServerManager to BootStrap. In the sample application there is no example about how to add the multiple Web Socket Servers and adding different Listener classes.
Coordinator
Oct 23, 2014 at 6:59 AM
The docs of SuperSocket should be helpful
http://docs.supersocket.net/