public override void ChannelRead(IChannelHandlerContext context, object message) { var buffer = message as IByteBuffer; Console.WriteLine($"收到訊息{buffer}"); if (buffer != null) { // 這裡可以處理接收到的資料 byte[] bytes = new byte[buffer.ReadableBytes]; buffer.ReadBytes(bytes); // 轉換為十六進位制字串以便顯示 string str = BitConverter.ToString(bytes).Replace(" ", ""); Console.WriteLine("接收服務端訊息: " + str.ToString() + "原始byte:" + bytes); } context.WriteAsync(message); //context.WriteAndFlushAsync(message); }