@Override public void operationComplete(WriteFuture future) { if (logger.isDebugEnabled()) { logger.debug("HttpEmptyPacketWriterFilter writing empty packet."); } wsnSession.getParent().write(emptyWsMessage); } });
final IoSessionEx parent = wsnSession.getParent(); if (WebSocketWireProtocol.HYBI_13.equals(wsVersion) || WebSocketWireProtocol.HYBI_8.equals(wsVersion)) {
public boolean isBalanceSupported() { String query = httpRequestURI.getQuery(); return ((query != null) && query.contains(".kl=Y")) || this.getParent().getAttribute(HttpAcceptor.BALANCEES_KEY) != null; }
@Override @SuppressWarnings("unchecked") public void initializeSession(IoSession session, ConnectFuture future) { WsnSession wsnSession = (WsnSession) session; if (wsnSession.isBalanceSupported()) { IoSession parent = wsnSession.getParent(); List<String> selectedBalanceeURIs = (List<String>) parent.getAttribute(HttpAcceptor.BALANCEES_KEY); wsnSession.setBalanceeURIs(selectedBalanceeURIs); } }
@Override protected void doFilterWrite(final NextFilter nextFilter, final WsnSession wsnSession, WriteRequest writeRequest) throws Exception { IoSession parent = wsnSession.getParent(); Encoding encoding = (Encoding) parent.getAttribute("encoding"); final WsMessage emptyWsMessage; final IoBufferAllocatorEx<?> allocator = wsnSession.getBufferAllocator(); switch(encoding) { case TEXT: emptyWsMessage = new WsTextMessage(allocator.wrap(allocator.allocate(0))); break; default: emptyWsMessage = new WsBinaryMessage(allocator.wrap(allocator.allocate(0))); } writeRequest.getFuture().addListener(new IoFutureListener<WriteFuture>() { @Override public void operationComplete(WriteFuture future) { if (logger.isDebugEnabled()) { logger.debug("HttpEmptyPacketWriterFilter writing empty packet."); } wsnSession.getParent().write(emptyWsMessage); } }); HttpResponseMessage message = (HttpResponseMessage) writeRequest.getMessage(); if ( message.getStatus() != HttpStatus.CLIENT_UNAUTHORIZED) { wsnSession.getFilterChain().remove(HttpEmptyPacketWriterFilter.this); } nextFilter.filterWrite(wsnSession, writeRequest); }