public void Dispose() { AsyncOnClientDisConnect?.Invoke(this); if (Client.Connected) { Client.Shutdown(SocketShutdown.Both); } Client.Close(); Client.Dispose(); AsyncOnClientDisConnected?.Invoke(this); }
private void ClientSocket_AsyncOnClientDisConnected(ClientSocket client) { client.AsyncOnMessageRecived -= ClientSocket_AsyncOnMessageRecived; client.AsyncOnErrMessageRecived -= ClientSocket_AsyncOnErrMessageRecived; client.AsyncOnClientDisConnect -= ClientSocket_AsyncOnClientDisConnect; client.AsyncOnClientDisConnected -= ClientSocket_AsyncOnClientDisConnected; client.AsyncOnClientDataRecived -= ClientSocket_AsyncOnClientDataRecived; AsyncOnClientDisConnected?.Invoke(client); lock (ClientSocketManagerLickObject) ClientSockets.Remove(client.IPAddress); }