private void SetConnectSuccess() { _finished = true; var removedCodec = true; removedCodec &= SafeRemoveEncoder(); _ctx.FireUserEventTriggered(new ProxyConnectionEvent(Protocol, AuthScheme, _proxyAddress, DestinationAddress)); removedCodec &= SafeRemoveDecoder(); if (removedCodec) { WritePendingWrites(); if (_flushedPrematurely) { _ctx.Flush(); } } else { // We are at inconsistent state because we failed to remove all codec handlers. Exception cause = new ProxyConnectException( "failed to remove all codec handlers added by the proxy handler; bug?", new InvalidOperationException()); FailPendingWrites(cause); _ctx.FireExceptionCaught(cause); _ctx.CloseAsync(); } }
private void SetConnectFailure(Exception cause) { _finished = true; if (!(cause is ProxyConnectException)) { cause = new ProxyConnectException( ExceptionMessage(cause.ToString()), cause); } SafeRemoveDecoder(); SafeRemoveEncoder(); FailPendingWrites(cause); _ctx.FireExceptionCaught(cause); _ctx.CloseAsync(); }