public void messageReceived(NextFilter nextFilter, IoSession session, Object message) throws Exception { if (message instanceof ByteBuffer) { release(session, ((ByteBuffer) message).remaining()); } nextFilter.messageReceived(session, message); } }
private void write(final SipMessage message, final IoSession io, final boolean listen) { final WriteFuture wf = io.write(message); if (listen) { wf.addListener(this); } }
private void storeRemainingInSession(ByteBuffer buf, IoSession session) { ByteBuffer remainingBuf = ByteBuffer.allocate(buf.capacity()); remainingBuf.setAutoExpand(true); remainingBuf.order(buf.order()); remainingBuf.put(buf); session.setAttribute(BUFFER, remainingBuf); } }
public Object clone() { DefaultIoFilterChainBuilder ret = new DefaultIoFilterChainBuilder(); for (Entry e : entries) { ret.addLast(e.getName(), e.getFilter()); } return ret; }
private void callPreviousFilterWrite(Entry entry, IoSession session, WriteRequest writeRequest) { try { entry.getFilter().filterWrite(entry.getNextFilter(), session, writeRequest); } catch (Throwable e) { writeRequest.getFuture().setWritten(false); fireExceptionCaught(session, e); } }
public ByteBuffer wrap(java.nio.ByteBuffer nioBuffer) { ensureNotDisposed(); PooledByteBuffer buf = allocateContainer(); buf.init(new UnexpandableByteBuffer(nioBuffer), false); buf.buf.init(); buf.setPooled(false); return buf; }
private void buildFilterChain(RegistrationRequest req, IoSession session) throws Exception { getFilterChainBuilder().buildFilterChain(session.getFilterChain()); req.config.getFilterChainBuilder().buildFilterChain( session.getFilterChain()); req.config.getThreadModel().buildFilterChain(session.getFilterChain()); }
public void sessionClosed(NextFilter nextFilter, IoSession session) throws Exception { try { session.getHandler().sessionClosed(session); } finally { // Remove all filters. session.getFilterChain().clear(); } }
/** * Determines whether or not the specified session is a UDP session. * * @param session The session to check. * @return <code>true</code> if the session is a UDP session, otherwise * <code>false</code>. */ public static boolean isUdp(final IoSession session) { return session.getTransportType().isConnectionless(); } }
public ByteBuffer allocate(int capacity, boolean direct) { ensureNotDisposed(); UnexpandableByteBuffer ubb = allocate0(capacity, direct); PooledByteBuffer buf = allocateContainer(); buf.init(ubb, true); return buf; }
private void removeSessionBuffer(IoSession session) { ByteBuffer buf = (ByteBuffer) session.removeAttribute(BUFFER); if (buf != null) { buf.release(); } }
public void exceptionCaught(NextFilter nextFilter, IoSession session, Throwable cause) throws Exception { session.getHandler().exceptionCaught(session, cause); }
public void sessionCreated(NextFilter nextFilter, IoSession session) throws Exception { session.getHandler().sessionCreated(session); }
/** * Creates a new instance with the specified <tt>timeout</tt>. */ public PooledByteBufferAllocator(int timeout) { setTimeout(timeout); expirer = new Expirer(); expirer.start(); }
@SuppressWarnings("unchecked") private void notifyListener(IoFutureListener l) { try { l.operationComplete(this); } catch (Throwable t) { ExceptionMonitor.getInstance().exceptionCaught(t); } } }
/** * Implement this method to perform real write operation with * the specified <code>writeRequest</code>. * * By default, this method is implemented to set the future to * 'not written' immediately. * * @param writeRequest Write request to make */ protected void write0(WriteRequest writeRequest) { writeRequest.getFuture().setWritten(false); }
public void messageReceived(NextFilter nextFilter, IoSession session, Object message) throws Exception { if (message instanceof ByteBuffer) { add(session, ((ByteBuffer) message).remaining()); } nextFilter.messageReceived(session, message); } }
private void buildFilterChain(RegistrationRequest req, IoSession session) throws Exception { this.getFilterChainBuilder().buildFilterChain(session.getFilterChain()); req.config.getFilterChainBuilder().buildFilterChain( session.getFilterChain()); req.config.getThreadModel().buildFilterChain(session.getFilterChain()); }