diff --git a/Service/Car/Codec/Decoder.cs b/Service/Car/Codec/Decoder.cs index e09bab5..a8dc698 100644 --- a/Service/Car/Codec/Decoder.cs +++ b/Service/Car/Codec/Decoder.cs @@ -1,8 +1,10 @@ -using DotNetty.Buffers; +using Dm.util; +using DotNetty.Buffers; using DotNetty.Codecs; using DotNetty.Transport.Channels; using HybirdFrameworkCore.Utils; using log4net; +using Newtonsoft.Json; using Service.Car.Common; using Service.Car.Msg; using Service.Car.Msg.Car.Req; @@ -59,7 +61,8 @@ public class Decoder : ByteToMessageDecoder byte[] data = new byte[length]; buffer.ReadBytes(data); - return data[5] switch + + BaseMsg msg = data[5] switch { 0x01 => ModelConvert.Decode(data), 0x03 => ModelConvert.Decode(data), @@ -69,6 +72,9 @@ public class Decoder : ByteToMessageDecoder 0x12 => ModelConvert.Decode(data), _ => new BaseMsg() }; + Log.Info($"receive original ={BitUtls.BytesToHexStr(data)} , data={JsonConvert.SerializeObject(msg)}"); + + return msg; } private IByteBuffer? FindDelimiter(IByteBuffer buffer) diff --git a/Service/Car/Handler/ElecMsgHandler.cs b/Service/Car/Handler/ElecMsgHandler.cs index 0e54d2d..b3741e2 100644 --- a/Service/Car/Handler/ElecMsgHandler.cs +++ b/Service/Car/Handler/ElecMsgHandler.cs @@ -2,6 +2,7 @@ using HybirdFrameworkCore.Autofac.Attribute; using HybirdFrameworkDriver.Session; using log4net; +using Newtonsoft.Json; using Service.Car.Msg.Car.Req; using Service.Car.Msg.Host.Resp; using Service.Car.Server; @@ -24,8 +25,8 @@ public class ElecMsgHandler : SimpleChannelInboundHandler, IBaseHandler /// protected override void ChannelRead0(IChannelHandlerContext ctx, ElecMsg msg) { - Log.Info($"receive ElecMsg = {msg}"); - IoSession? ioSession = CarServerMgr.CarServer?.SessionMgr.GetSession(msg.CarNo); + Log.Info($"receive ElecMsg = {JsonConvert.SerializeObject(msg)}"); + IoSession? ioSession = SessionMgr.GetSession(msg.CarNo); ioSession?.BusinessMap.AddOrUpdate("ElecMsg", msg, ((s, o) => msg)); ioSession?.BusinessMap.AddOrUpdate("Connected", true, ((s, o) => true)); diff --git a/Service/Car/Handler/HeartBeatMsgHandler.cs b/Service/Car/Handler/HeartBeatMsgHandler.cs index 1f3f0f8..1bcdb63 100644 --- a/Service/Car/Handler/HeartBeatMsgHandler.cs +++ b/Service/Car/Handler/HeartBeatMsgHandler.cs @@ -2,6 +2,7 @@ using HybirdFrameworkCore.Autofac.Attribute; using HybirdFrameworkDriver.Session; using log4net; +using Newtonsoft.Json; using Service.Car.Msg.Car.Req; using Service.Car.Msg.Host.Resp; using Service.Car.Server; @@ -26,8 +27,8 @@ public class HeartBeatMsgHandler : SimpleChannelInboundHandler, IB protected override void ChannelRead0(IChannelHandlerContext ctx, HeartBeatMsg msg) { - Log.Info($"receive HeartBeatMsg = {msg}"); - IoSession? ioSession = CarServerMgr.CarServer?.SessionMgr.GetSession(ctx.Channel.Id.ToString()); + Log.Info($"receive HeartBeatMsg = {JsonConvert.SerializeObject(msg)}"); + IoSession? ioSession = SessionMgr.GetSession(ctx.Channel.Id.ToString()); if (ioSession != null && ioSession.Key != msg.CarNo) { CarServerMgr.CarServer?.SessionMgr.ChangeSessionKey(ioSession, msg.CarNo); diff --git a/Service/Car/Handler/LockMsgRespHandler.cs b/Service/Car/Handler/LockMsgRespHandler.cs index 7ee18dc..591232d 100644 --- a/Service/Car/Handler/LockMsgRespHandler.cs +++ b/Service/Car/Handler/LockMsgRespHandler.cs @@ -1,6 +1,7 @@ using DotNetty.Transport.Channels; using HybirdFrameworkCore.Autofac.Attribute; using log4net; +using Newtonsoft.Json; using Service.Car.Msg.Car.Resp; using Service.Car.Msg.Host.Req; using Service.Car.Server; @@ -26,7 +27,7 @@ public class LockMsgRespHandler : SimpleChannelInboundHandler, IBas { LockMsg? lockMsg = CarServerMgr.CarServer.LockMsgPair.Req; - Log.Info($"receive LockMsgResp = {msg}, lockMsg={lockMsg}"); + Log.Info($"receive LockMsgResp = {JsonConvert.SerializeObject(msg)}, lockMsg={JsonConvert.SerializeObject(lockMsg)}"); if (lockMsg != null && lockMsg.CarNo == msg.CarNo) { CarServerMgr.CarServer.LockMsgPair.SetResp(msg); diff --git a/Service/Car/Handler/SetParamMsgRespHandler.cs b/Service/Car/Handler/SetParamMsgRespHandler.cs index 9a7efad..619e201 100644 --- a/Service/Car/Handler/SetParamMsgRespHandler.cs +++ b/Service/Car/Handler/SetParamMsgRespHandler.cs @@ -1,6 +1,7 @@ using DotNetty.Transport.Channels; using HybirdFrameworkCore.Autofac.Attribute; using log4net; +using Newtonsoft.Json; using Service.Car.Msg.Car.Resp; using Service.Car.Server; @@ -22,7 +23,7 @@ public class SetParamMsgRespHandler : SimpleChannelInboundHandler protected override void ChannelRead0(IChannelHandlerContext ctx, SetParamMsgResp msg) { - Log.Info($"receive SetParamMsgResp = {msg}"); + Log.Info($"receive SetParamMsgResp = {JsonConvert.SerializeObject(msg)}"); CarServerMgr.CarServer.SetParamMsgPair.SetResp(msg); } } diff --git a/Service/Car/Handler/SettleConfirmMsgRespHandler.cs b/Service/Car/Handler/SettleConfirmMsgRespHandler.cs index f2d024b..3f31198 100644 --- a/Service/Car/Handler/SettleConfirmMsgRespHandler.cs +++ b/Service/Car/Handler/SettleConfirmMsgRespHandler.cs @@ -1,6 +1,7 @@ using DotNetty.Transport.Channels; using HybirdFrameworkCore.Autofac.Attribute; using log4net; +using Newtonsoft.Json; using Service.Car.Msg.Car.Resp; using Service.Car.Server; @@ -23,7 +24,7 @@ public class SettleConfirmMsgRespHandler : SimpleChannelInboundHandler protected override void ChannelRead0(IChannelHandlerContext ctx, SettleConfirmMsgResp msg) { - Log.Info($"receive SettleConfirmMsgResp = {msg}"); + Log.Info($"receive SettleConfirmMsgResp = {JsonConvert.SerializeObject(msg)}"); CarServerMgr.CarServer.SettleConfirmMsgPair.SetResp(msg); } } diff --git a/Service/Car/Handler/UnLockMsgRespHandler.cs b/Service/Car/Handler/UnLockMsgRespHandler.cs index a35cbf4..a67b707 100644 --- a/Service/Car/Handler/UnLockMsgRespHandler.cs +++ b/Service/Car/Handler/UnLockMsgRespHandler.cs @@ -1,6 +1,7 @@ using DotNetty.Transport.Channels; using HybirdFrameworkCore.Autofac.Attribute; using log4net; +using Newtonsoft.Json; using Service.Car.Msg.Car.Resp; using Service.Car.Msg.Host.Req; using Service.Car.Server; @@ -25,7 +26,7 @@ public class UnLockMsgRespHandler : SimpleChannelInboundHandler, protected override void ChannelRead0(IChannelHandlerContext ctx, UnLockMsgResp msg) { UnLockMsg? unLockMsg = CarServerMgr.CarServer.UnLockMsgPair.Req; - Log.Info($"receive UnLockMsgResp = {msg} unLockMsg={unLockMsg}"); + Log.Info($"receive UnLockMsgResp = {JsonConvert.SerializeObject(msg)} unLockMsg={JsonConvert.SerializeObject(unLockMsg)}"); if (unLockMsg != null && unLockMsg.CarNo == msg.CarNo) { CarServerMgr.CarServer.UnLockMsgPair.SetResp(msg);