Merge branch 'master' of http://192.168.0.12:13000/sc/ForwardingServer
This commit is contained in:
commit
a470d9fa34
1 file changed
+19
-7
+19
-7
@@ -73,11 +73,13 @@ namespace ForwardingServer
|
||||
}
|
||||
else
|
||||
{
|
||||
Personm deserializedPerson = JsonSerializer.Deserialize<Personm>(DAT)!;
|
||||
DATA.MachineTable.Rows.Add(client.Id, client.IP, 30, "/" + deserializedPerson.SERVEREnterprise,
|
||||
deserializedPerson.SERVERMachineName, deserializedPerson.MachineVer);
|
||||
Console.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-DD HH:mm:ss:fff") + " [LINK ID " + client.Id + " IP " + client.IP + "]\nDATA =" + DAT);
|
||||
|
||||
if (IsValidJson(DAT))
|
||||
{
|
||||
Personm deserializedPerson = JsonSerializer.Deserialize<Personm>(DAT)!;
|
||||
DATA.MachineTable.Rows.Add(client.Id, client.IP, 30, "/" + deserializedPerson.SERVEREnterprise,
|
||||
deserializedPerson.SERVERMachineName, deserializedPerson.MachineVer);
|
||||
Console.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-DD HH:mm:ss:fff") + " [LINK ID " + client.Id + " IP " + client.IP + "]\nDATA =" + DAT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -107,7 +109,17 @@ namespace ForwardingServer
|
||||
await service.StartAsync();//启动
|
||||
|
||||
Console.WriteLine("TcpServer:Run");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 辅助方法检查JSON格式
|
||||
private static bool IsValidJson(string jsonString)
|
||||
{
|
||||
if (string.IsNullOrEmpty(jsonString))
|
||||
return false;
|
||||
|
||||
jsonString = jsonString.Trim();
|
||||
return (jsonString.StartsWith("{") && jsonString.EndsWith("}")) ||
|
||||
(jsonString.StartsWith("[") && jsonString.EndsWith("]"));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user