public SendHandler() { MultithreadEventLoopGroup eventLoopGroup = new MultithreadEventLoopGroup(); for (; ;) { try { ConcurrentDictionary <string, ISocketChannel> map = GatewayService.getChannels(); foreach (string s in map.Keys) { var writer = new RunWriter { channel = map[s] }; eventLoopGroup.Execute(writer);/*.WriteAndFlushAsync(Unpooled.WrappedBuffer(Encoding.UTF8.GetBytes("Hello world")));*/ } Thread.Sleep(5000); } catch (Exception ex) { Console.WriteLine(ex.Message); } } }
public override void ChannelInactive(IChannelHandlerContext context) { string uuid = context.Channel.Id.ToString(); GatewayService.removeGatewayChannel(uuid); }
public override void ChannelActive(IChannelHandlerContext context) { string uuid = context.Channel.Id.ToString(); GatewayService.addGatewayChannel(uuid, (ISocketChannel)context.Channel); }