阳光铭岛tbox测试

master
rszn 4 months ago
parent 1e79ceba4b
commit 35e279276a

@ -17,13 +17,14 @@ public class Decoder : ByteToMessageDecoder
private static readonly ILog Log = LogManager.GetLogger(typeof(Decoder)); 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<object> output) protected override void Decode(IChannelHandlerContext context, IByteBuffer input, List<object> output)
{ {
if (_fixedLength <= input.ReadableBytes) if (_fixedLength <= input.ReadableBytes)
{ {
byte[] bytes = new byte[_fixedLength]; byte[] bytes = new byte[_fixedLength-1];
input.SkipBytes(1);
input.ReadBytes(bytes); input.ReadBytes(bytes);
//TODO 实际开发时去掉 //TODO 实际开发时去掉
@ -31,7 +32,7 @@ public class Decoder : ByteToMessageDecoder
Log.Info($"receive {BitUtls.BytesToHexStr(bytes)}"); 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( Log.Info(
$"receive id={id} {BitUtls.BytesToHexStr(BitConverter.GetBytes(0x1882D0F3))} {BitUtls.BytesToHexStr(BitConverter.GetBytes(4090528280))}"); $"receive id={id} {BitUtls.BytesToHexStr(BitConverter.GetBytes(0x1882D0F3))} {BitUtls.BytesToHexStr(BitConverter.GetBytes(4090528280))}");
BaseMsg baseMsg = id switch BaseMsg baseMsg = id switch

Loading…
Cancel
Save