Пример #1
0
        public override void ExceptionCaught(IChannelHandlerContext ctx, Exception cause)
        {
            NettyChannel channel = NettyChannel.GetOrAddChannel(ctx.Channel, _url, _handler);

            try
            {
                _handler.CaughtAsync(channel, cause);
            }
            finally
            {
                NettyChannel.RemoveChannelIfDisconnected(ctx.Channel);
            }
        }
Пример #2
0
        public override async Task DisconnectAsync(IChannelHandlerContext ctx)
        {
            NettyChannel channel = NettyChannel.GetOrAddChannel(ctx.Channel, _url, _handler);

            try
            {
                await _handler.DisconnectAsync(channel);
            }
            finally
            {
                NettyChannel.RemoveChannelIfDisconnected(ctx.Channel);
            }
        }
Пример #3
0
        public override async Task WriteAsync(IChannelHandlerContext ctx, object msg)
        {
            await base.WriteAsync(ctx, msg);

            NettyChannel channel = NettyChannel.GetOrAddChannel(ctx.Channel, _url, _handler);

            try
            {
                await _handler.SentAsync(channel, msg);
            }
            finally
            {
                NettyChannel.RemoveChannelIfDisconnected(ctx.Channel);
            }
        }
Пример #4
0
        public override void ChannelRead(IChannelHandlerContext ctx, object msg)
        {
            NettyChannel channel = NettyChannel.GetOrAddChannel(ctx.Channel, _url, _handler);

            try
            {
                //Console.WriteLine("channel read:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
                _handler.RecivedAsync(channel, msg).Wait();
                // Console.WriteLine("channel read completed:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
            }
            finally
            {
                NettyChannel.RemoveChannelIfDisconnected(ctx.Channel);
            }
        }
Пример #5
0
        protected override void Encode(IChannelHandlerContext context, object message, IByteBuffer output)
        {
            DotNetty.Transport.Channels.IChannel ch = context.Channel;
            NettyChannel channel = NettyChannel.GetOrAddChannel(ch, _url, _handler);

            try
            {
                //Console.WriteLine("encode:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
                _codec.Encode(channel, output, message);
                //Console.WriteLine("encoded:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
            }
            finally
            {
                NettyChannel.RemoveChannelIfDisconnected(ch);
            }
        }