@Override protected void doSessionIdle(IoSessionEx session, IdleStatus status) throws Exception { WsnSession wsnSession = SESSION_KEY.get(session); if (wsnSession != null) { IoFilterChain filterChain = wsnSession.getFilterChain(); filterChain.fireSessionIdle(status); } }
@Override protected void doSessionIdle(IoSessionEx session, IdleStatus status) throws Exception { WsnSession wsnSession = SESSION_KEY.get(session); IoFilterChain filterChain = wsnSession.getFilterChain(); filterChain.fireSessionIdle(status); }
@Override protected void doMessageReceived(IoSessionEx session, Object message) throws Exception { WsnSession wsnSession = SESSION_KEY.get(session); IoFilterChain filterChain = wsnSession.getFilterChain();
@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); }
IoFilterChain filterChain = wsnSession.getFilterChain(); IoBufferAllocatorEx<? extends WsBuffer> allocator = wsnSession.getBufferAllocator();