//--------------------------------------------------------------------- public Task Start(IPAddress ip_address, int port) { var builder = new ContainerBuilder(); builder.RegisterModule(new ConfigurationSettingsReader("autofac")); this.GatewaySessionListenerContainer = builder.Build(); var gatewaySessionFactory = new GatewaySessionFactory(); this.timer = new System.Timers.Timer(); this.timer.Interval = 3000; this.timer.Elapsed += (obj, evt) => { int count = 0; IChannelGroup g = this.ChannelGroup; if (g != null) { count = g.Count; } string title = Gateway.Instance.ConsoleTitle; string version = Gateway.Instance.Version; Console.Title = string.Format("{0} {1} ConnectionCount={2}", title, version, count); }; this.timer.Start(); return(this.gatewayRunner.Start(ip_address, port, gatewaySessionFactory)); }
//--------------------------------------------------------------------- public Task Start(IPAddress ip_address, int port) { var builder = new ContainerBuilder(); builder.RegisterModule(new ConfigurationSettingsReader("autofac")); this.GatewaySessionListenerContainer = builder.Build(); var gatewaySessionFactory = new GatewaySessionFactory(); return this.gatewayRunner.Start(ip_address, port, gatewaySessionFactory); }
//--------------------------------------------------------------------- public Task Start(IPAddress ip_address, int port) { var builder = new ContainerBuilder(); builder.RegisterModule(new ConfigurationSettingsReader("autofac")); this.GatewaySessionListenerContainer = builder.Build(); var gatewaySessionFactory = new GatewaySessionFactory(); return(this.gatewayRunner.Start(ip_address, port, gatewaySessionFactory)); }
//--------------------------------------------------------------------- public async Task Start(IPAddress ip_address, int port, GatewaySessionFactory factory) { this.bootstrap .Group(this.bossGroup, this.workerGroup) .Channel <TcpServerSocketChannel>() .Option(ChannelOption.SoBacklog, 100) .Option(ChannelOption.SoKeepalive, true) .Option(ChannelOption.TcpNodelay, true) .Handler(new LoggingHandler(LogLevel.INFO)) .ChildHandler(new ActionChannelInitializer <ISocketChannel>(channel => { IChannelPipeline pipeline = channel.Pipeline; pipeline.AddLast(new LengthFieldPrepender( ByteOrder.LittleEndian, 2, 0, false)); pipeline.AddLast(new LengthFieldBasedFrameDecoder( ByteOrder.LittleEndian, ushort.MaxValue, 0, 2, 0, 2, true)); pipeline.AddLast(new GatewayChannelHandler(factory)); })); this.bootstrapChannel = await this.bootstrap.BindAsync(ip_address, port); this.timer = new System.Timers.Timer(); this.timer.Interval = 3000; this.timer.Elapsed += (obj, evt) => { //var t = obj as System.Timers.Timer; int count = 0; lock (lockSetSession) { count = this.setSession.Count; } string title = Gateway.Instance.ConsoleTitle; string version = Gateway.Instance.Version; Console.Title = string.Format("{0} {1} ConnectionCount={2}", title, version, count); }; this.timer.Start(); }
//--------------------------------------------------------------------- public async Task Start(IPAddress ip_address, int port, GatewaySessionFactory factory) { this.bootstrap .Group(this.bossGroup, this.workerGroup) .Channel<TcpServerSocketChannel>() .Option(ChannelOption.SoBacklog, 100) .Option(ChannelOption.SoKeepalive, true) .Option(ChannelOption.TcpNodelay, true) .Handler(new LoggingHandler(LogLevel.INFO)) .ChildHandler(new ActionChannelInitializer<ISocketChannel>(channel => { IChannelPipeline pipeline = channel.Pipeline; pipeline.AddLast(new LengthFieldPrepender( ByteOrder.LittleEndian, 2, 0, false)); pipeline.AddLast(new LengthFieldBasedFrameDecoder( ByteOrder.LittleEndian, ushort.MaxValue, 0, 2, 0, 2, true)); pipeline.AddLast(new GatewayChannelHandler(factory)); })); this.bootstrapChannel = await this.bootstrap.BindAsync(ip_address, port); this.timer = new System.Timers.Timer(); this.timer.Interval = 3000; this.timer.Elapsed += (obj, evt) => { //var t = obj as System.Timers.Timer; int count = 0; lock (lockSetSession) { count = this.setSession.Count; } string title = Gateway.Instance.ConsoleTitle; string version = Gateway.Instance.Version; Console.Title = string.Format("{0} {1} ConnectionCount={2}", title, version, count); }; this.timer.Start(); }
//--------------------------------------------------------------------- public async Task Start(IPAddress ip_address, int port, GatewaySessionFactory factory) { this.bootstrap .Group(this.bossGroup, this.workerGroup) .Channel <TcpServerSocketChannel>() .Option(ChannelOption.SoBacklog, 100) .Option(ChannelOption.SoKeepalive, false) .Option(ChannelOption.TcpNodelay, true) .Handler(new LoggingHandler(LogLevel.INFO)) .ChildHandler(new ActionChannelInitializer <ISocketChannel>(channel => { IChannelPipeline pipeline = channel.Pipeline; pipeline.AddLast(new LengthFieldPrepender( ByteOrder.LittleEndian, 2, 0, false)); pipeline.AddLast(new LengthFieldBasedFrameDecoder( ByteOrder.LittleEndian, ushort.MaxValue, 0, 2, 0, 2, true)); pipeline.AddLast(new GatewayChannelHandler(factory)); })); this.bootstrapChannel = await this.bootstrap.BindAsync(ip_address, port); }
//--------------------------------------------------------------------- public GatewayChannelHandler(GatewaySessionFactory factory) { this.factory = factory; }