code: public void register(Session session, int ops) throws ClosedChannelException {
          if (sessions.containsKey(session.getID())) {
              throw new IllegalStateException("Altready registered session");
          }
          
          SelectionKey selKey;
          try {
              selKey = session.getChannel().register(selector, ops, session);
          } catch (ClosedChannelException e) {
              Logger.error("Error while register channel to selector. {}", session, e);
              throw e;
          }
          session.setSelectionKey(selKey);
      }
docs: register session to Selector in order to detect IO events.
  @param session
  @param ops interest IO operations, such as SelectionKey.OP_ACCEPT, SelectionKey.OP_CONNECT, SelectionKey.OP_READ, SelectionKey.OP_WRITE
  @throws ClosedChannelException