private void updateSession(Session session) throws ClosedChannelException {
    if (session.getCurrentState() == Session.IoState.READ && session.readBuffer.remaining() > 0) {
      if (this.sessionManager.getReadTimeout() > 0) {
        if (session.getNextTimeout() > System.currentTimeMillis()) {
          /** 读操作已超时 */
          session.setNextTimeout(System.currentTimeMillis() + this.sessionManager.getReadTimeout());
          addTimeoutSession(session);
        }
      }
      /** session注册socket读事件 */
      session.getSocketChannel().register(selector, SelectionKey.OP_READ, session);

    } else if (session.getCurrentState() == Session.IoState.WRITE
        && session.writeBuffer.remaining() > 0) {
      if (this.sessionManager.getWriteTimeout() > 0) {
        if (session.getNextTimeout() > System.currentTimeMillis()) {
          /** 写操作已超时 */
          session
              .setNextTimeout(System.currentTimeMillis() + this.sessionManager.getWriteTimeout());
          addTimeoutSession(session);
        }
      }
      /** session注册socket读事件 */
      session.getSocketChannel().register(selector, SelectionKey.OP_WRITE, session);
    } else {
      /** 关闭 session */
      close(session);
    }
  }