1、调试补偿模板过程中,屏蔽温度补充;2、增加 通讯发送不成功后,重发,3、修复运动到位判断
This commit is contained in:
@@ -156,7 +156,7 @@ namespace HexcalMC.Hexcal
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new Exception("WatchThread异常" + e);
|
||||
//throw new Exception("WatchThread异常" + e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,15 +284,32 @@ namespace HexcalMC.Hexcal
|
||||
}
|
||||
}
|
||||
|
||||
public bool TrySendData(Socket socket, byte[] data)
|
||||
{
|
||||
int sentBytes = socket.Send(data);
|
||||
return sentBytes == data.Length; // 检查是否完全发送成功
|
||||
}
|
||||
public void SendMessageToAllClients(string strMsg)
|
||||
{
|
||||
byte[] arrMsg = Encoding.Default.GetBytes(strMsg);
|
||||
foreach (Socket soc in _dictSocket.Values)
|
||||
{
|
||||
soc.Send(arrMsg);
|
||||
bool success = TrySendData(soc, arrMsg);
|
||||
if (!success)
|
||||
{
|
||||
// 如果发送失败,进行重发逻辑
|
||||
int attemptCount = 0;
|
||||
const int maxAttempts = 3;
|
||||
while (!success && attemptCount < maxAttempts)
|
||||
{
|
||||
success = TrySendData(soc, arrMsg);
|
||||
attemptCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void SendMessageToAllClients(byte[] arrMsg)
|
||||
{
|
||||
foreach (Socket soc in _dictSocket.Values)
|
||||
|
||||
Reference in New Issue
Block a user