static ServerBuildParameter BuildOption()
        {
            var parameter = new ServerBuildParameter();

            parameter.NetEventOnConnect                             = NetEventOnConnect;
            parameter.NetEventOnCloese                              = NetEventOnCloese;
            parameter.NetEventOnReceive                             = NetEventOnReceive;
            parameter.serverOption.Name                             = "TestServer";
            parameter.serverOption.Listeners                        = new ListenOptions[1];
            parameter.serverOption.Listeners[0]                     = new ListenOptions();
            parameter.serverOption.Listeners[0].Ip                  = "Any";
            parameter.serverOption.Listeners[0].Port                = 11021;
            parameter.serverOption.Listeners[0].BackLog             = 100;
            parameter.serverOption.Listeners[0].MaxRecvPacketSize   = 512;     //TODO 적용 안됨
            parameter.serverOption.Listeners[0].MaxReceivBufferSize = 512 * 3; //TODO 적용 안됨
            parameter.serverOption.Listeners[0].MaxSendPacketSize   = 1024;
            parameter.serverOption.Listeners[0].MaxSendingSize      = 4096;
            parameter.serverOption.Listeners[0].MaxSendReTryCount   = 3;

            return(parameter);
        }
Beispiel #2
0
        static async Task RunAsyncVer2()
        {
            var parameter = new ServerBuildParameter();

            parameter.NetEventOnConnect                             = NetEventOnConnect;
            parameter.NetEventOnCloese                              = NetEventOnCloese;
            parameter.NetEventOnReceive                             = NetEventOnReceive;
            parameter.serverOption.Name                             = "TestServer";
            parameter.serverOption.Listeners                        = new ListenOptions[1];
            parameter.serverOption.Listeners[0]                     = new ListenOptions();
            parameter.serverOption.Listeners[0].Ip                  = "Any";
            parameter.serverOption.Listeners[0].Port                = 11021;
            parameter.serverOption.Listeners[0].BackLog             = 100;
            parameter.serverOption.Listeners[0].MaxRecvPacketSize   = 512;
            parameter.serverOption.Listeners[0].MaxReceivBufferSize = 512 * 3;
            parameter.serverOption.Listeners[0].MaxSendPacketSize   = 1024;
            parameter.serverOption.Listeners[0].MaxSendingSize      = 4096;
            parameter.serverOption.Listeners[0].MaxReTryCount       = 3;

            var pipelineFilterFactoryList = new List <IPipelineFilterFactory>();

            pipelineFilterFactoryList.Add(new DefaultPipelineFilterFactory <BinaryPipelineFilter>());

            var server = new SuperSocketServer();

            server.CreateSocketServer(parameter, pipelineFilterFactoryList);

            Logger = SuperSocketServer.GetLogger();

            await server.StartAsync();

            Logger.LogInformation("The server is started.");
            while (Console.ReadLine().ToLower() != "c")
            {
                continue;
            }

            await server.StopAsync();
        }