예제 #1
0
  /** {@inheritDoc} */
  public void write(S session, WriteRequest writeRequest) {
    WriteRequestQueue writeRequestQueue = session.getWriteRequestQueue();

    writeRequestQueue.offer(session, writeRequest);

    if (!session.isWriteSuspended()) {
      this.flush(session);
    }
  }
예제 #2
0
  /** Deal with session ready for the read or write operations, or both. */
  private void process(S session) {
    // Process Reads
    if (isReadable(session) && !session.isReadSuspended()) {
      read(session);
    }

    // Process writes
    if (isWritable(session) && !session.isWriteSuspended()) {
      // add the session to the queue, if it's not already there
      if (session.setScheduledForFlush(true)) {
        flushingSessions.add(session);
      }
    }
  }
예제 #3
0
  /** {@inheritDoc} */
  public void updateTrafficControl(S session) {
    //
    try {
      setInterestedInRead(session, !session.isReadSuspended());
    } catch (Exception e) {
      IoFilterChain filterChain = session.getFilterChain();
      filterChain.fireExceptionCaught(e);
    }

    try {
      setInterestedInWrite(
          session, !session.getWriteRequestQueue().isEmpty(session) && !session.isWriteSuspended());
    } catch (Exception e) {
      IoFilterChain filterChain = session.getFilterChain();
      filterChain.fireExceptionCaught(e);
    }
  }