Esempio n. 1
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();
        }
        static async Task RunAsync()
        {
            var parameter = BuildOption();

            var pipelineFilterList = new List <IPipelineFilter>();

            pipelineFilterList.Add(new BinaryPipelineFilter());

            var server = new SuperSocketServer();

            server.CreateSocketServer(parameter, pipelineFilterList);

            Logger = SuperSocketServer.GetLogger();

            await server.StartAsync();

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

            await server.StopAsync();
        }