| | |
| | | using System.Text; |
| | | using System.Text.Json; |
| | | using System.IO; |
| | | using WIDESEAWCS_Model.Models; |
| | | |
| | | namespace WIDESEAWCS_Tasks.SocketServer |
| | | { |
| | |
| | | break; |
| | | } |
| | | |
| | | if(message == lastMessage) |
| | | // 按客户端去重:检查是否与该客户端上次消息相同 |
| | | lock (_syncRoot) |
| | | { |
| | | // 重复消息,忽略 |
| | | continue; |
| | | if (_clientLastMessage.TryGetValue(clientId, out var prev) && message == prev) |
| | | { |
| | | continue; |
| | | } |
| | | _clientLastMessage[clientId] = message; |
| | | } |
| | | |
| | | // 更新客户端状态 |
| | |
| | | { |
| | | // 判断是否为 JSON 格式 |
| | | bool isJsonFormat = TryParseJsonSilent(message); |
| | | _ = MessageReceived.Invoke(message, isJsonFormat, client, robotCrane); |
| | | _ = MessageReceived.Invoke(message, isJsonFormat, client); |
| | | } |
| | | catch { } |
| | | } |