public void enqueueEventIfNecessary(final IoSessionEvent evt) {
        logger.debug("??? >> Enqueue {}", evt);

        if (proxyIoSession.getRequest() instanceof SocksProxyRequest) {
            // No reconnection used
            evt.deliverEvent();
            return;
        }

        if (proxyIoSession.getHandler().isHandshakeComplete()) {
            evt.deliverEvent();
        } else {
            if (evt.getType() == IoSessionEventType.CLOSED) {
                if (proxyIoSession.isAuthenticationFailed()) {
                    proxyIoSession.getConnector().cancelConnectFuture();
                    discardSessionQueueEvents();
                    evt.deliverEvent();
                } else {
                    discardSessionQueueEvents();
                }
            } else if (evt.getType() == IoSessionEventType.OPENED) {
                // Enqueue event cause it will not reach IoHandler but deliver it to enable 
                // session creation.
                enqueueSessionEvent(evt);
                evt.deliverEvent();
            } else {
                enqueueSessionEvent(evt);
            }
        }
    }
public void enqueueEventIfNecessary ( final IoSessionEvent evt ) { logger . debug ( "??? >> Enqueue {}" , evt ) ; if ( proxyIoSession . getRequest ( ) instanceof SocksProxyRequest ) { evt . deliverEvent ( ) ; return ; } if ( proxyIoSession . getHandler ( ) . isHandshakeComplete ( ) ) { evt . deliverEvent ( ) ; } else { if ( evt . getType ( ) == IoSessionEventType . CLOSED ) { if ( proxyIoSession . isAuthenticationFailed ( ) ) { proxyIoSession . getConnector ( ) . cancelConnectFuture ( ) ; discardSessionQueueEvents ( ) ; evt . deliverEvent ( ) ; } else { discardSessionQueueEvents ( ) ; } } else if ( evt . getType ( ) == IoSessionEventType . OPENED ) { enqueueSessionEvent ( evt ) ; evt . deliverEvent ( ) ; } else { enqueueSessionEvent ( evt ) ; } } }
Event is enqueued only if necessary :
- socks proxies do not need the reconnection feature so events are always
forwarded for these.
- http proxies events will be enqueued while handshake has not been completed
or until connection was closed.
If connection was prematurely closed previous events are discarded and only the
session closed is delivered.

@param evt the event to enqueue