static async Task Main(string[] args) { _ = new PerformanceCounterListener(); IUdpBootstrap bootstrap = UdpFactory.Bootstrap(); bootstrap.ConfigurationGlobalOptions(options => { }); bootstrap.ConfigurationGlobalFilter((pipeline) => { pipeline.Add(new UdpFilter_2()); }); await bootstrap.BuildAsync(); IUdpChannel s_channel = await bootstrap.CreateChannelAsync(); await s_channel.StartAsync(s_p); IUdpChannel c_channel = await bootstrap.CreateChannelAsync(); await c_channel.StartAsync(c_p); int count = 0; byte[] com = System.Text.Encoding.UTF8.GetBytes("send::::::::"); byte[] countBytes = System.Text.Encoding.UTF8.GetBytes($"{count}___1"); while (true) { string str = Console.ReadLine(); if (str == "") { for (int i = 0; i < 1000; i++) { M.session.Write(Program.s_p, com); M.session.Write(Program.s_p, countBytes); await M.session.FlushAsync(); } count++; //for (int i = 1; i <= 100; i++) //{ // for (int j = 1; j <= 5; j++) // { // string com = $"{count}____{i}______{j}"; // var bytes = System.Text.Encoding.UTF8.GetBytes(com); // M.session.Write(Program.s_p, bytes); // } // await M.session.FlushAsync(); //} } else if (str == "c") { await M.session.CloseAsync(); } else if (str == "s") { return; } } }
public KcpChannel(KcpOptions options, IUdpChannel channel, IKcpScheduler scheduler, Action <IFilterPipeline <IKcpSession> > handler) { base.ConfigurationSelfOptions(options); base.ConfigurationSelfFilter(handler); this.scheduler = scheduler; this.channel = channel; this.channel.ConfigurationSelfFilter((pipeline) => { pipeline.Add(this); }); this.orderOperators = BinaryOrderOperatorsFactory.GetOperators(options.Order); this.scheduler.Register(this); }
public override async Task StopAsync() { if (this.isStop) { return; } this.isStop = true; this.runnableUnits = null; this.scheduler.Unregister(this); await base.StopAsync(); if (this.channel != null) { await this.channel.StopAsync(); this.channel = null; } this.session = null; this.controller.Dispose(); }