using DotNetty.Buffers; using DotNetty.Codecs; using DotNetty.Transport.Channels; using log4net; using Service.TBox.Msg; namespace Service.TBox.Codec; public class Encoder : MessageToByteEncoder { private static readonly ILog Log = LogManager.GetLogger(typeof(Encoder)); /// /// /// /// /// /// protected override void Encode(IChannelHandlerContext context, BaseMsg obj, IByteBuffer output) { byte[] bytes = obj.ToBytes(); byte[] result = { 0, bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7], 0, 0, 0, 0 }; output.WriteBytes(result); } }