|
@@ -141,7 +141,7 @@ namespace YSAI.Core.socket.tcpClient
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
void ServerData()
|
|
void ServerData()
|
|
|
{
|
|
{
|
|
|
- Byte[] readBuffer = new Byte[1024];
|
|
|
|
|
|
|
+ Byte[] readBuffer = new Byte[1024 * 10];
|
|
|
while (!ServerDataMonitorSwitch.IsCancellationRequested)
|
|
while (!ServerDataMonitorSwitch.IsCancellationRequested)
|
|
|
{
|
|
{
|
|
|
try
|
|
try
|
|
@@ -152,19 +152,22 @@ namespace YSAI.Core.socket.tcpClient
|
|
|
Int32 bytes = networkStream.Read(readBuffer, 0, alen); //读取数据
|
|
Int32 bytes = networkStream.Read(readBuffer, 0, alen); //读取数据
|
|
|
if (bytes > 0)
|
|
if (bytes > 0)
|
|
|
{
|
|
{
|
|
|
- OnEventHandler?.Invoke(this, new EventResult(true,$"[ {SocketTcpClientData.Steps.消息接收} ]接收服务端数据成功", ByteTool.ByteTrimEnd(readBuffer),@enum.ResultType.Bytes)); //数据传递出去
|
|
|
|
|
|
|
+ OnEventHandler?.Invoke(this, new EventResult(true, $"[ {SocketTcpClientData.Steps.消息接收} ]接收服务端数据成功", ByteTool.ByteTrimEnd(readBuffer), @enum.ResultType.Bytes)); //数据传递出去
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- OnEventHandler?.Invoke(this, new EventResult(false,$"[ {SocketTcpClientData.Steps.消息接收} ]接收服务端发送过来的数据长度错误(小于等于零)")); //数据传递出去
|
|
|
|
|
|
|
+ OnEventHandler?.Invoke(this, new EventResult(false, $"[ {SocketTcpClientData.Steps.消息接收} ]接收服务端发送过来的数据长度错误(小于等于零)")); //数据传递出去
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ Thread.Sleep(10);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
|
{
|
|
{
|
|
|
OnEventHandler?.Invoke(this, new EventResult(false, $"[ {SocketTcpClientData.Steps.消息接收} ]服务端消息接收异常:{ex.Message}")); //数据传递出去
|
|
OnEventHandler?.Invoke(this, new EventResult(false, $"[ {SocketTcpClientData.Steps.消息接收} ]服务端消息接收异常:{ex.Message}")); //数据传递出去
|
|
|
}
|
|
}
|
|
|
- Thread.Sleep(10);
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
/// <summary>
|
|
/// <summary>
|