@SuppressWarnings("unchecked") private Queue<WriteRequest> getWriteRequestQueue(IoSession session) { return (Queue<WriteRequest>) session.getAttribute(WRITE_REQUEST_QUEUE); }
/** * Closes streams */ public void sessionClosed(IoSession session) throws Exception { final InputStream in = (InputStream) session.getAttribute(KEY_IN); final OutputStream out = (OutputStream) session.getAttribute(KEY_OUT); try { in.close(); } finally { out.close(); } }
/** * Forwards read data to input stream. */ @Override public void messageReceived(final IoSession session, final Object buf) { final IoSessionInputStream in = (IoSessionInputStream) session.getAttribute(KEY_IN); in.write((ByteBuffer) buf); }
/** * Forwards read data to input stream. */ public void messageReceived(IoSession session, Object buf) { final IoSessionInputStream in = (IoSessionInputStream) session .getAttribute(KEY_IN); in.write((ByteBuffer) buf); }
public void execute(NextCommand next, IoSession session, Object message) throws Exception { next = (NextCommand) session.getAttribute(NEXT_COMMAND); if (next != null) { next.execute(session, message); } } };
/** * Delegates the method call to the * {@link SingleSessionIoHandler#sessionIdle(IdleStatus)} method of the * handler assigned to this session. */ public void sessionIdle(IoSession session, IdleStatus status) throws Exception { SingleSessionIoHandler handler = (SingleSessionIoHandler) session .getAttribute(HANDLER); handler.sessionIdle(status); }
/** * Delegates the method call to the * {@link SingleSessionIoHandler#messageReceived(Object)} method of the * handler assigned to this session. */ public void messageReceived(IoSession session, Object message) throws Exception { SingleSessionIoHandler handler = (SingleSessionIoHandler) session .getAttribute(HANDLER); handler.messageReceived(message); }
public static void info(IoSession session, String message, Throwable cause) { Logger log = getLogger(session); if (log.isInfoEnabled()) { log.info(String.valueOf(session.getAttribute(PREFIX)) + message, cause); } }
public static void debug(IoSession session, String message) { Logger log = getLogger(session); if (log.isDebugEnabled()) { log.debug(String.valueOf(session.getAttribute(PREFIX)) + message); } }
public static void info(IoSession session, String message) { Logger log = getLogger(session); if (log.isInfoEnabled()) { log.info(String.valueOf(session.getAttribute(PREFIX)) + message); } }
public static void warn(IoSession session, String message) { Logger log = getLogger(session); if (log.isWarnEnabled()) { log.warn(String.valueOf(session.getAttribute(PREFIX)) + message); } }
public static void warn(IoSession session, String message, Throwable cause) { Logger log = getLogger(session); if (log.isWarnEnabled()) { log.warn(String.valueOf(session.getAttribute(PREFIX)) + message, cause); } }
public static void error(IoSession session, String message, Throwable cause) { Logger log = getLogger(session); if (log.isErrorEnabled()) { log.error(String.valueOf(session.getAttribute(PREFIX)) + message, cause); } }
/** * Delegates the method call to the * {@link SingleSessionIoHandler#sessionOpened()} method of the handler * assigned to this session. */ public void sessionOpened(IoSession session) throws Exception { SingleSessionIoHandler handler = (SingleSessionIoHandler) session .getAttribute(HANDLER); handler.sessionOpened(); }
public void encode(final IoSession session, final Object msg, final ProtocolEncoderOutput out) throws Exception { m_log.debug("Encoding TURN/STUN message: {}", msg); final StunMessage stunMessage = (StunMessage) msg; final TurnStunMessageMapper mapper = (TurnStunMessageMapper) session.getAttribute( "REMOTE_ADDRESS_MAP"); final StunMessageVisitor<ByteBuffer> visitor = new SendIndicationStunMessageVisitor(out, mapper); stunMessage.accept(visitor); }
private Context getContext(final IoSession session) { Context ctx = (Context) session.getAttribute(CONTEXT); if (ctx == null) { ctx = new Context(); session.setAttribute(CONTEXT, ctx); } return ctx; }
private ProtocolEncoder getEncoder(IoSession session) throws Exception { ProtocolEncoder encoder = (ProtocolEncoder) session .getAttribute(ENCODER); if (encoder == null) { encoder = factory.getEncoder(); session.setAttribute(ENCODER, encoder); } return encoder; }
private ProtocolDecoder getDecoder(IoSession session) throws Exception { ProtocolDecoder decoder = (ProtocolDecoder) session .getAttribute(DECODER); if (decoder == null) { decoder = factory.getDecoder(); session.setAttribute(DECODER, decoder); } return decoder; }
private Context getContext(IoSession session) { Context ctx = (Context) session.getAttribute(CONTEXT); if (ctx == null) { ctx = new Context(); session.setAttribute(CONTEXT, ctx); } return ctx; }
private static SessionBuffer getSessionBuffer(IoSession session) { synchronized (session) { SessionBuffer buf = (SessionBuffer) session.getAttribute(KEY); if (buf == null) { buf = new SessionBuffer(session); session.setAttribute(KEY, buf); } return buf; } }