private void FailureRaised ( ISocketConnection sender, Exception ex ) { // here we should log the exception Console.WriteLine(ex.ToString()); // we disconnect the faulty client sender.BeginDisconnect(); }
private void FailureRaised (ISocketConnection sender, Exception ex) { // here we should log the exception // we disconnect the faulty client sender.BeginDisconnect(); }
public void Disconnect() { if (!Disposed) { FLastException = null; if (Connected) { FExceptionEvent.Reset(); if (FSocketConnection != null) { WaitHandle[] wait = new WaitHandle[] { FDisconnectEvent, FExceptionEvent }; FSocketConnection.BeginDisconnect(); int signaled = WaitHandle.WaitAny(wait, FConnectTimeout, false); switch (signaled) { case 0: DoDisconnect(); break; case 1: //----- Exception! DoDisconnect(); break; default: //----- TimeOut! FLastException = new TimeoutException("Disconnect timeout."); break; } } } } }
private void MessageSent(ISocketConnection sender) { // In case the last message sent to the client was to warn it an error occured // we should have its handle in there and just close the connection if (clientsToDisconnect.Contains(sender.SocketHandle)) { clientsToDisconnect.Remove(sender.SocketHandle); sender.BeginDisconnect(); } }