Compare commits
4
Commits
acdf42509e
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46e32f24d1 | ||
|
|
a470d9fa34 | ||
|
|
2e2eb1be5b | ||
|
|
0946d595ed |
No files matched your search
+1
-3
@@ -10,6 +10,7 @@ using TouchSocket.Core;
|
|||||||
using TouchSocket.Http;
|
using TouchSocket.Http;
|
||||||
using TouchSocket.Http.WebSockets;
|
using TouchSocket.Http.WebSockets;
|
||||||
using TouchSocket.Sockets;
|
using TouchSocket.Sockets;
|
||||||
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||||
|
|
||||||
|
|
||||||
namespace ForwardingServer
|
namespace ForwardingServer
|
||||||
@@ -69,7 +70,6 @@ namespace ForwardingServer
|
|||||||
// using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));
|
// using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));
|
||||||
|
|
||||||
await AsyncTcpServer.service.SendAsync(s_, bodyString);
|
await AsyncTcpServer.service.SendAsync(s_, bodyString);
|
||||||
LogGing.LogGingDATA(bodyString);
|
|
||||||
|
|
||||||
DATA.Person deserializedPerson = JsonSerializer.Deserialize<DATA.Person>(bodyString)!;
|
DATA.Person deserializedPerson = JsonSerializer.Deserialize<DATA.Person>(bodyString)!;
|
||||||
|
|
||||||
@@ -111,8 +111,6 @@ namespace ForwardingServer
|
|||||||
e.Context.Response.SetStatus(200, "success");
|
e.Context.Response.SetStatus(200, "success");
|
||||||
e.Context.Response.SetContent(Encoding.UTF8.GetBytes(dat.ToCharArray()));
|
e.Context.Response.SetContent(Encoding.UTF8.GetBytes(dat.ToCharArray()));
|
||||||
await e.Context.Response.AnswerAsync();
|
await e.Context.Response.AnswerAsync();
|
||||||
|
|
||||||
LogGing.LogGingDATA(dat);
|
|
||||||
}
|
}
|
||||||
catch (TimeoutException)
|
catch (TimeoutException)
|
||||||
{
|
{
|
||||||
|
|||||||
+13
-4
@@ -67,20 +67,19 @@ namespace ForwardingServer
|
|||||||
drEmployee.EndEdit();
|
drEmployee.EndEdit();
|
||||||
drEmployee.AcceptChanges();
|
drEmployee.AcceptChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
LogGing.LogGingDATA("[LINK ID " + client.Id + " IP " + client.IP + "]\nDATA =" + DAT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (IsValidJson(DAT))
|
||||||
{
|
{
|
||||||
Personm deserializedPerson = JsonSerializer.Deserialize<Personm>(DAT)!;
|
Personm deserializedPerson = JsonSerializer.Deserialize<Personm>(DAT)!;
|
||||||
DATA.MachineTable.Rows.Add(client.Id, client.IP, 30, "/" + deserializedPerson.SERVEREnterprise,
|
DATA.MachineTable.Rows.Add(client.Id, client.IP, 30, "/" + deserializedPerson.SERVEREnterprise,
|
||||||
deserializedPerson.SERVERMachineName, deserializedPerson.MachineVer);
|
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);
|
Console.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-DD HH:mm:ss:fff") + " [LINK ID " + client.Id + " IP " + client.IP + "]\nDATA =" + DAT);
|
||||||
LogGing.LogGingDATA("[LINK ID " + client.Id + " IP " + client.IP + "]\nDATA =" + DAT);
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -112,5 +111,15 @@ namespace ForwardingServer
|
|||||||
Console.WriteLine("TcpServer:Run");
|
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