2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-06-27 05:23:13 +00:00

AutoReconnect

This commit is contained in:
2022-08-11 21:28:16 +03:00
parent af94ce318a
commit 21a2061fc4
12 changed files with 355 additions and 154 deletions

View File

@ -158,8 +158,8 @@ public class TCPSocket : ISocket
{
state = SocketState.Established;
//OnConnect?.Invoke();
Receiver?.NetworkConnect(this);
//OnConnect?.Invoke();
Receiver?.NetworkConnect(this);
Begin();
rt.Trigger(true);
}
@ -396,32 +396,32 @@ public class TCPSocket : ISocket
public void Close()
{
if (state != SocketState.Closed)// && state != SocketState.Terminated)
if (state == SocketState.Closed)
return; // && state != SocketState.Terminated)
state = SocketState.Closed;
if (sock.Connected)
{
state = SocketState.Closed;
if (sock.Connected)
{
try
{
sock.Shutdown(SocketShutdown.Both);
}
catch
{
}
}
try
{
sendBufferQueue?.Clear();
Receiver?.NetworkClose(this);
sock.Shutdown(SocketShutdown.Both);
}
catch (Exception ex)
catch
{
Global.Log(ex);
}
}
try
{
sendBufferQueue?.Clear();
Receiver?.NetworkClose(this);
}
catch (Exception ex)
{
Global.Log(ex);
}
}
public void Send(byte[] message)
@ -543,7 +543,7 @@ public class TCPSocket : ISocket
public void Destroy()
{
Close();
receiveNetworkBuffer = null;
@ -560,7 +560,7 @@ public class TCPSocket : ISocket
OnDestroy?.Invoke(this);
OnDestroy = null;
}
}
public ISocket Accept()
{