public void sessionRead()

in core/src/main/java/org/apache/mina/service/idlechecker/IndexedIdleChecker.java [120:163]


    public void sessionRead(AbstractIoSession session, long timeInMs) {
        if (IS_DEBUG) {
            LOG.debug("session read event, compute idle index of session {}", session);
        }

        // remove from the old index position
        Integer oldIndex = session.getAttribute(READ_IDLE_INDEX);

        if (oldIndex != null && readIdleSessionIndex[oldIndex] != null) {
            if (IS_DEBUG) {
                LOG.debug("remove for old index {}", oldIndex);
            }

            readIdleSessionIndex[oldIndex].remove(session);
        }

        long idleTimeInMs = session.getConfig().getIdleTimeInMillis(IdleStatus.READ_IDLE);

        // is idle enabled ?
        if (idleTimeInMs <= 0L) {
            if (IS_DEBUG) {
                LOG.debug("no read idle configuration");
            }
        } else {
            int nextIdleTimeInSeconds = (int) ((timeInMs + idleTimeInMs) / 1000L);
            int index = nextIdleTimeInSeconds % MAX_IDLE_TIME_IN_SEC;

            if (IS_DEBUG) {
                LOG.debug("computed index : {}", index);
            }

            if (readIdleSessionIndex[index] == null) {
                readIdleSessionIndex[index] = Collections
                        .newSetFromMap(new ConcurrentHashMap<AbstractIoSession, Boolean>());
            }

            if (IS_DEBUG) {
                LOG.debug("marking session {} idle for index {}", session, index);
            }

            readIdleSessionIndex[index].add(session);
            session.setAttribute(READ_IDLE_INDEX, index);
        }
    }