Start SuperSocket by Configuration

Keywords: Start by Configuration, Configuration

The configuration file of SuperSocket

Same as Asp.Net Core, SuperSocket uses the JSON configuration file appsettings.json. We just need leave the file in root of the application folder and make sure it can be copied to the output directory of he build.

How to Start Server with the configuration file

Actually, you don't need do anything else except writing the normal startup code.

var host = SuperSocketHostBuilder.Create<StringPackageInfo, CommandLinePipelineFilter>()
    .UsePackageHandler(async (s, p) =>
    {
        // handle packages
    })
    .ConfigureLogging((hostCtx, loggingBuilder) =>
    {
        loggingBuilder.AddConsole();
    })
    .Build();

await host.RunAsync();

The format of the configuration file (appsettings.json)

It is a sample:

{
    "serverOptions": {
        "name": "GameMsgServer",
        "listeners": [
            {
                "ip": "Any",
                "port": "2020"
            },
            {
                "ip": "192.168.3.1",
                "port": "2020"
            }
        ]
    }
}

Options: