Update SocketClient.cs

pull/1/head
a.bozhenov 5 years ago
parent 98a8f402ae
commit d59165b70d

@ -3,6 +3,7 @@ using System.Collections.Concurrent;
using System.Net; using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
using System.Threading; using System.Threading;
using System.Threading.Tasks;
using ZeroLevel.Services.Pools; using ZeroLevel.Services.Pools;
using ZeroLevel.Services.Serialization; using ZeroLevel.Services.Serialization;
@ -337,8 +338,7 @@ namespace ZeroLevel.Network
private void ReceiveAsyncCallback(IAsyncResult ar) private void ReceiveAsyncCallback(IAsyncResult ar)
{ {
try try
{ {
EnsureConnection();
var count = _stream.EndRead(ar); var count = _stream.EndRead(ar);
if (count > 0) if (count > 0)
{ {
@ -350,9 +350,10 @@ namespace ZeroLevel.Network
// TODO or not TODO // TODO or not TODO
Thread.Sleep(1); Thread.Sleep(1);
} }
EnsureConnection();
if (Status == SocketClientStatus.Working if (Status == SocketClientStatus.Working
|| Status == SocketClientStatus.Initialized) || Status == SocketClientStatus.Initialized)
{ {
_stream.BeginRead(_buffer, 0, DEFAULT_RECEIVE_BUFFER_SIZE, ReceiveAsyncCallback, null); _stream.BeginRead(_buffer, 0, DEFAULT_RECEIVE_BUFFER_SIZE, ReceiveAsyncCallback, null);
} }
} }

Loading…
Cancel
Save

Powered by TurnKey Linux.