diff --git a/Service/TBox/Codec/Decoder.cs b/Service/TBox/Codec/Decoder.cs index f96dfc3..7ca0e25 100644 --- a/Service/TBox/Codec/Decoder.cs +++ b/Service/TBox/Codec/Decoder.cs @@ -17,13 +17,14 @@ public class Decoder : ByteToMessageDecoder private static readonly ILog Log = LogManager.GetLogger(typeof(Decoder)); - private readonly int _fixedLength = 18; + private readonly int _fixedLength = 13; protected override void Decode(IChannelHandlerContext context, IByteBuffer input, List output) { if (_fixedLength <= input.ReadableBytes) { - byte[] bytes = new byte[_fixedLength]; + byte[] bytes = new byte[_fixedLength-1]; + input.SkipBytes(1); input.ReadBytes(bytes); //TODO 实际开发时去掉 @@ -31,7 +32,7 @@ public class Decoder : ByteToMessageDecoder Log.Info($"receive {BitUtls.BytesToHexStr(bytes)}"); - int id = BitConverter.ToInt32(new byte[] { bytes[3], bytes[2], bytes[1], bytes[0] }, 0); + int id = BitConverter.ToInt32(new byte[] { bytes[4], bytes[3], bytes[2], bytes[1] }, 0); Log.Info( $"receive id={id} {BitUtls.BytesToHexStr(BitConverter.GetBytes(0x1882D0F3))} {BitUtls.BytesToHexStr(BitConverter.GetBytes(4090528280))}"); BaseMsg baseMsg = id switch