|
|
@ -90,8 +90,26 @@ namespace SlnMesnac.TouchSocket
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
// string message = $"\x00\x00\x00+{{\"image_path\": \"{msg}\"}}";
|
|
|
|
// string message = $"\x00\x00\x00+{{\"image_path\": \"{msg}\"}}";
|
|
|
|
string message = $"\x00\x00\x00+{{\"image_path\": \"{msg}\"}}";
|
|
|
|
|
|
|
|
tcpClient.Send(message);
|
|
|
|
// 构建请求对象
|
|
|
|
|
|
|
|
var request = new { image_path = msg };
|
|
|
|
|
|
|
|
// 序列化请求对象为 JSON 字符串
|
|
|
|
|
|
|
|
string message = JsonConvert.SerializeObject(request);
|
|
|
|
|
|
|
|
// 将 JSON 字符串转换为字节数组
|
|
|
|
|
|
|
|
byte[] messageBytes = Encoding.UTF8.GetBytes(message);
|
|
|
|
|
|
|
|
// 发送请求的长度(4字节)
|
|
|
|
|
|
|
|
byte[] lengthBytes = BitConverter.GetBytes(messageBytes.Length);
|
|
|
|
|
|
|
|
if (BitConverter.IsLittleEndian)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Array.Reverse(lengthBytes); // 如果系统是小端序,需要反转字节顺序
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
tcpClient.Send(lengthBytes, 0, lengthBytes.Length);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tcpClient.Send(messageBytes, 0, messageBytes.Length);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// string message = $"\x00\x00\x00+{{\"image_path\": \"{msg}\"}}";
|
|
|
|
|
|
|
|
// tcpClient.Send(message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|