/** * Closes the session. * * @param message the error message */ protected void closeSession(final String message) { closeSession(message, null); }
/** * Send any write requests which were queued whilst waiting for handshaking to complete. * * @throws Exception If we can't flush the pending write requests */ protected synchronized void flushPendingWriteRequests() throws Exception { LOGGER.debug(" flushPendingWriteRequests()"); if (writeRequestQueue == null) { return; } Event scheduledWrite; while ((scheduledWrite = writeRequestQueue.poll()) != null) { LOGGER.debug(" Flushing buffered write request: {}", scheduledWrite.data); getProxyFilter().filterWrite(scheduledWrite.nextFilter, getSession(), (WriteRequest) scheduledWrite.data); } // Free queue writeRequestQueue = null; }
/** * Signals that the handshake has finished. */ protected final void setHandshakeComplete() { synchronized (this) { handshakeComplete = true; } ProxyIoSession proxyIoSession = getProxyIoSession(); proxyIoSession.getConnector().fireConnected(proxyIoSession.getSession()).awaitUninterruptibly(); LOGGER.debug(" handshake completed"); // Connected OK try { proxyIoSession.getEventQueue().flushPendingSessionEvents(); flushPendingWriteRequests(); } catch (Exception ex) { LOGGER.error("Unable to flush pending write requests", ex); } }
/** * Closes the session. * * @param message the error message * @param t the exception which caused the session closing */ protected void closeSession(final String message, final Throwable t) { if (t != null) { LOGGER.error(message, t); proxyIoSession.setAuthenticationFailed(true); } else { LOGGER.error(message); } getSession().closeNow(); }
/** * Signals that the handshake has finished. */ protected final void setHandshakeComplete() { synchronized (this) { handshakeComplete = true; } ProxyIoSession proxyIoSession = getProxyIoSession(); proxyIoSession.getConnector().fireConnected(proxyIoSession.getSession()).awaitUninterruptibly(); LOGGER.debug(" handshake completed"); // Connected OK try { proxyIoSession.getEventQueue().flushPendingSessionEvents(); flushPendingWriteRequests(); } catch (Exception ex) { LOGGER.error("Unable to flush pending write requests", ex); } }
/** * Closes the session. * * @param message the error message * @param t the exception which caused the session closing */ protected void closeSession(final String message, final Throwable t) { if (t != null) { LOGGER.error(message, t); proxyIoSession.setAuthenticationFailed(true); } else { LOGGER.error(message); } getSession().close(true); }
/** * Send any write requests which were queued whilst waiting for handshaking to complete. * * @throws Exception If we can't flush the pending write requests */ protected synchronized void flushPendingWriteRequests() throws Exception { LOGGER.debug(" flushPendingWriteRequests()"); if (writeRequestQueue == null) { return; } Event scheduledWrite; while ((scheduledWrite = writeRequestQueue.poll()) != null) { LOGGER.debug(" Flushing buffered write request: {}", scheduledWrite.data); getProxyFilter().filterWrite(scheduledWrite.nextFilter, getSession(), (WriteRequest) scheduledWrite.data); } // Free queue writeRequestQueue = null; }
/** * Signals that the handshake has finished. */ protected final void setHandshakeComplete() { synchronized (this) { handshakeComplete = true; } ProxyIoSession proxyIoSession = getProxyIoSession(); proxyIoSession.getConnector() .fireConnected(proxyIoSession.getSession()) .awaitUninterruptibly(); LOGGER.debug(" handshake completed"); // Connected OK try { proxyIoSession.getEventQueue().flushPendingSessionEvents(); flushPendingWriteRequests(); } catch (Exception ex) { LOGGER.error("Unable to flush pending write requests", ex); } }
/** * Closes the session. * * @param message the error message */ protected void closeSession(final String message) { closeSession(message, null); }
/** * Closes the session. * * @param message the error message * @param t the exception which caused the session closing */ protected void closeSession(final String message, final Throwable t) { if (t != null) { LOGGER.error(message, t); proxyIoSession.setAuthenticationFailed(true); } else { LOGGER.error(message); } getSession().closeNow(); }
/** * Send any write requests which were queued whilst waiting for handshaking to complete. */ protected synchronized void flushPendingWriteRequests() throws Exception { LOGGER.debug(" flushPendingWriteRequests()"); if (writeRequestQueue == null) { return; } Event scheduledWrite; while ((scheduledWrite = writeRequestQueue.poll()) != null) { LOGGER.debug(" Flushing buffered write request: {}", scheduledWrite.data); getProxyFilter().filterWrite(scheduledWrite.nextFilter, getSession(), (WriteRequest) scheduledWrite.data); } // Free queue writeRequestQueue = null; }
/** * Closes the session. * * @param message the error message */ protected void closeSession(final String message) { closeSession(message, null); }
/** * Writes data to the proxy server. * * @param nextFilter the next filter * @param data Data buffer to be written. */ protected WriteFuture writeData(final NextFilter nextFilter, final IoBuffer data) { // write net data ProxyHandshakeIoBuffer writeBuffer = new ProxyHandshakeIoBuffer(data); LOGGER.debug(" session write: {}", writeBuffer); WriteFuture writeFuture = new DefaultWriteFuture(getSession()); getProxyFilter().writeData(nextFilter, getSession(), new DefaultWriteRequest(writeBuffer, writeFuture), true); return writeFuture; }
/** * Writes data to the proxy server. * * @param nextFilter the next filter * @param data Data buffer to be written. * @return A Future for the write operation */ protected WriteFuture writeData(final NextFilter nextFilter, final IoBuffer data) { // write net data ProxyHandshakeIoBuffer writeBuffer = new ProxyHandshakeIoBuffer(data); LOGGER.debug(" session write: {}", writeBuffer); WriteFuture writeFuture = new DefaultWriteFuture(getSession()); getProxyFilter().writeData(nextFilter, getSession(), new DefaultWriteRequest(writeBuffer, writeFuture), true); return writeFuture; }
/** * Writes data to the proxy server. * * @param nextFilter the next filter * @param data Data buffer to be written. * @return A Future for the write operation */ protected WriteFuture writeData(final NextFilter nextFilter, final IoBuffer data) { // write net data ProxyHandshakeIoBuffer writeBuffer = new ProxyHandshakeIoBuffer(data); LOGGER.debug(" session write: {}", writeBuffer); WriteFuture writeFuture = new DefaultWriteFuture(getSession()); getProxyFilter().writeData(nextFilter, getSession(), new DefaultWriteRequest(writeBuffer, writeFuture), true); return writeFuture; }