Esempio n. 1
0
 protected override void ChannelRead0(IChannelHandlerContext ctx, byte[] msg)
 {
     ThreadPool.QueueUserWorkItem((object state) =>
     {
         try
         {
             byte[] bytes        = (byte[])state;
             DotNettyData result = (DotNettyData)ByteExtension.ByteArrayToObject(bytes);
             requestManager.CompleteRequest(result.SerialNumber, result);
         }
         catch (Exception ex)
         {
             LogsManager.Error("处理服务端结果失败");
         }
     }, msg);
 }
Esempio n. 2
0
        protected override void ChannelRead0(IChannelHandlerContext context, byte[] bytes)
        {
            DotNettyData data = (DotNettyData)ByteExtension.ByteArrayToObject(bytes);

            if (serviceRecieveHandler != null && data != null)
            {
                Task.Run(() =>
                {
                    try
                    {
                        var handlerResult = serviceRecieveHandler(data);
                        if (handlerResult != null)
                        {
                            context.WriteAndFlushAsync(handlerResult);
                        }
                    }
                    catch (Exception ex)
                    {
                        //ex.Error();
                    }
                });
            }
        }
Esempio n. 3
0
 protected override void Encode(IChannelHandlerContext context, DotNettyData message, IByteBuffer output)
 {
     byte[] bytes = ByteExtension.ObjectToByteArray(message);
     output.WriteBytes(bytes);
 }