/** * Processes newly created I/O session. This method dispatches the event * notification to the {@link IOEventDispatch#connected(IOSession)} method. */ @Override protected void sessionCreated(final SelectionKey key, final IOSession session) { try { this.eventDispatch.connected(session); } catch (final CancelledKeyException ex) { queueClosedSession(session); } catch (final RuntimeException ex) { handleRuntimeException(ex); } }
/** * Processes closed I/O session. This method dispatches the event * notification to the {@link IOEventDispatch#disconnected(IOSession)} * method. */ @Override protected void sessionClosed(final IOSession session) { try { this.eventDispatch.disconnected(session); } catch (final CancelledKeyException ex) { // ignore } catch (final RuntimeException ex) { handleRuntimeException(ex); } }
/** * Processes timed out I/O session. This method dispatches the event * notification to the {@link IOEventDispatch#timeout(IOSession)} method. */ @Override protected void sessionTimedOut(final IOSession session) { try { this.eventDispatch.timeout(session); } catch (final CancelledKeyException ex) { queueClosedSession(session); } catch (final RuntimeException ex) { handleRuntimeException(ex); } }
this.eventDispatch.inputReady(session); if (!session.hasBufferedInput()) { it.remove();
/** * Processes {@link SelectionKey#OP_WRITE} event on the given selection key. * This method dispatches the event notification to the * {@link IOEventDispatch#outputReady(IOSession)} method. */ @Override protected void writable(final SelectionKey key) { final IOSession session = getSession(key); try { this.eventDispatch.outputReady(session); } catch (final CancelledKeyException ex) { queueClosedSession(session); key.attach(null); } catch (final RuntimeException ex) { handleRuntimeException(ex); } }
this.eventDispatch.inputReady(session); if (!session.hasBufferedInput()) { it.remove();
/** * Processes {@link SelectionKey#OP_WRITE} event on the given selection key. * This method dispatches the event notification to the * {@link IOEventDispatch#outputReady(IOSession)} method. */ @Override protected void writable(final SelectionKey key) { final IOSession session = getSession(key); try { this.eventDispatch.outputReady(session); } catch (final CancelledKeyException ex) { queueClosedSession(session); key.attach(null); } catch (final RuntimeException ex) { handleRuntimeException(ex); } }
/** * Processes {@link SelectionKey#OP_READ} event on the given selection key. * This method dispatches the event notification to the * {@link IOEventDispatch#inputReady(IOSession)} method. */ @Override protected void readable(final SelectionKey key) { final IOSession session = getSession(key); try { // Try to gently feed more data to the event dispatcher // if the session input buffer has not been fully exhausted // (the choice of 5 iterations is purely arbitrary) for (int i = 0; i < 5; i++) { this.eventDispatch.inputReady(session); if (!session.hasBufferedInput() || (session.getEventMask() & SelectionKey.OP_READ) == 0) { break; } } if (session.hasBufferedInput()) { this.bufferingSessions.add(session); } } catch (final CancelledKeyException ex) { queueClosedSession(session); key.attach(null); } catch (final RuntimeException ex) { handleRuntimeException(ex); } }
/** * Processes newly created I/O session. This method dispatches the event * notification to the {@link IOEventDispatch#connected(IOSession)} method. */ @Override protected void sessionCreated(final SelectionKey key, final IOSession session) { try { this.eventDispatch.connected(session); } catch (final CancelledKeyException ex) { queueClosedSession(session); } catch (final RuntimeException ex) { handleRuntimeException(ex); } }
/** * Processes timed out I/O session. This method dispatches the event * notification to the {@link IOEventDispatch#timeout(IOSession)} method. */ @Override protected void sessionTimedOut(final IOSession session) { try { this.eventDispatch.timeout(session); } catch (final CancelledKeyException ex) { queueClosedSession(session); } catch (final RuntimeException ex) { handleRuntimeException(ex); } }
/** * Processes closed I/O session. This method dispatches the event * notification to the {@link IOEventDispatch#disconnected(IOSession)} * method. */ @Override protected void sessionClosed(final IOSession session) { try { this.eventDispatch.disconnected(session); } catch (final CancelledKeyException ex) { // ignore } catch (final RuntimeException ex) { handleRuntimeException(ex); } }
/** * Processes {@link SelectionKey#OP_READ} event on the given selection key. * This method dispatches the event notification to the * {@link IOEventDispatch#inputReady(IOSession)} method. */ @Override protected void readable(final SelectionKey key) { final IOSession session = getSession(key); try { // Try to gently feed more data to the event dispatcher // if the session input buffer has not been fully exhausted // (the choice of 5 iterations is purely arbitrary) for (int i = 0; i < 5; i++) { this.eventDispatch.inputReady(session); if (!session.hasBufferedInput() || (session.getEventMask() & SelectionKey.OP_READ) == 0) { break; } } if (session.hasBufferedInput()) { this.bufferingSessions.add(session); } } catch (final CancelledKeyException ex) { queueClosedSession(session); key.attach(null); } catch (final RuntimeException ex) { handleRuntimeException(ex); } }