コード例 #1
0
ファイル: SendHandler.cs プロジェクト: zhige777/Test
        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);
                }
            }
        }
コード例 #2
0
        public override void ChannelInactive(IChannelHandlerContext context)
        {
            string uuid = context.Channel.Id.ToString();

            GatewayService.removeGatewayChannel(uuid);
        }
コード例 #3
0
        public override void ChannelActive(IChannelHandlerContext context)
        {
            string uuid = context.Channel.Id.ToString();

            GatewayService.addGatewayChannel(uuid, (ISocketChannel)context.Channel);
        }