Commit 7978abc0 authored by 潘栩锋's avatar 潘栩锋 🚴

1. 为了调试通讯内容,FObjSys 添加 NLog, logger分别为 FObjSysOfServer 与 FObjSysOfClient

parent c5be3a15
...@@ -68,6 +68,14 @@ ...@@ -68,6 +68,14 @@
<Name>Misc</Name> <Name>Misc</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.2</Version>
</PackageReference>
<PackageReference Include="NLog">
<Version>4.6.6</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.
......
...@@ -19,6 +19,11 @@ namespace FObjBase ...@@ -19,6 +19,11 @@ namespace FObjBase
/// </summary> /// </summary>
public class FObjSys : IFObjSysAsClient, IFObjSysAsServer public class FObjSys : IFObjSysAsClient, IFObjSysAsServer
{ {
/// <summary>
/// nlog调试信息
/// </summary>
static NLog.Logger loggerServer = NLog.LogManager.GetLogger("FObjSysOfServer");
static NLog.Logger loggerClient = NLog.LogManager.GetLogger("FObjSysOfClient");
/// <summary> /// <summary>
/// 全局 当前正在操作的 fobj系统 /// 全局 当前正在操作的 fobj系统
/// </summary> /// </summary>
...@@ -782,6 +787,10 @@ namespace FObjBase ...@@ -782,6 +787,10 @@ namespace FObjBase
void CConnConnectAction(IFConn conn) void CConnConnectAction(IFConn conn)
{ {
TCPCConn cc = (TCPCConn)conn; TCPCConn cc = (TCPCConn)conn;
if (loggerClient.IsDebugEnabled)
{
loggerClient.Debug($"CConnConnectAction {cc.sock.RemoteEndPoint} conn.IsConnected={conn.IsConnected}");
}
KeyValuePair<TCPCConn, List<UInt32>> cc_kv; KeyValuePair<TCPCConn, List<UInt32>> cc_kv;
try try
...@@ -806,6 +815,14 @@ namespace FObjBase ...@@ -806,6 +815,14 @@ namespace FObjBase
/// <param name="conn"></param> /// <param name="conn"></param>
void SConnConnectAction(IFConn conn) void SConnConnectAction(IFConn conn)
{ {
if (loggerServer.IsDebugEnabled)
{
if (conn is TCPConn)
{
loggerServer.Debug($"SConnConnectAction {(conn as TCPConn).sock.RemoteEndPoint} IsConnected={conn.IsConnected}");
}
}
//通知obj 连接状态 //通知obj 连接状态
foreach (UInt32 objid in m_serverConnectedNotifyObjID) foreach (UInt32 objid in m_serverConnectedNotifyObjID)
{ {
...@@ -1000,6 +1017,14 @@ namespace FObjBase ...@@ -1000,6 +1017,14 @@ namespace FObjBase
if (!p.TryParse(packet)) if (!p.TryParse(packet))
return false; return false;
if (loggerClient.IsDebugEnabled)
{
string p_json = Newtonsoft.Json.JsonConvert.SerializeObject(p, Newtonsoft.Json.Formatting.Indented);
loggerClient.Debug($"ParsePacketInClient {(conn as TCPConn).sock.RemoteEndPoint} packet={p_json}");
}
conn.TranID = p.magic; conn.TranID = p.magic;
{ {
if (Process(conn, p.srcid, p.destid, p.magic, p.info, p.buf, out byte[] retdata) == 0) if (Process(conn, p.srcid, p.destid, p.magic, p.info, p.buf, out byte[] retdata) == 0)
...@@ -1071,11 +1096,15 @@ namespace FObjBase ...@@ -1071,11 +1096,15 @@ namespace FObjBase
/// <returns></returns> /// <returns></returns>
bool ParsePacketInServer(byte[] packet, IFConn conn) bool ParsePacketInServer(byte[] packet, IFConn conn)
{ {
//DateTime dt2 = DateTime.Now;
Pack_Proto p = new Pack_Proto(); Pack_Proto p = new Pack_Proto();
if (!p.TryParse(packet)) if (!p.TryParse(packet))
return false; return false;
if (loggerServer.IsDebugEnabled)
{
string p_json = Newtonsoft.Json.JsonConvert.SerializeObject(p, Newtonsoft.Json.Formatting.Indented);
loggerClient.Debug($"ParsePacketInServer {(conn as TCPConn).sock.RemoteEndPoint} packet={p_json}");
}
conn.TranID = p.magic; conn.TranID = p.magic;
{ {
if (Process(conn, p.srcid, p.destid, p.magic, p.info, p.buf, out byte[] retdata) == 0) if (Process(conn, p.srcid, p.destid, p.magic, p.info, p.buf, out byte[] retdata) == 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment