Tbox报文日志

master
lxw 5 months ago
parent c0c8ed1576
commit afd70753f2

@ -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<ElecMsg>(data),
0x03 => ModelConvert.Decode<HeartBeatMsg>(data),
@ -69,6 +72,9 @@ public class Decoder : ByteToMessageDecoder
0x12 => ModelConvert.Decode<SetParamMsgResp>(data),
_ => new BaseMsg()
};
Log.Info($"receive original ={BitUtls.BytesToHexStr(data)} , data={JsonConvert.SerializeObject(msg)}");
return msg;
}
private IByteBuffer? FindDelimiter(IByteBuffer buffer)

@ -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<ElecMsg>, IBaseHandler
/// <exception cref="NotImplementedException"></exception>
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));

@ -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<HeartBeatMsg>, 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);

@ -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<LockMsgResp>, 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);

@ -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<SetParamMsgRes
/// <exception cref="NotImplementedException"></exception>
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);
}
}

@ -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<SettleCon
/// <exception cref="NotImplementedException"></exception>
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);
}
}

@ -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<UnLockMsgResp>,
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);

Loading…
Cancel
Save