public void sessionWritten()

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


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

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

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

            writeIdleSessionIndex[oldIndex].remove(session);
        }

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

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

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

            writeIdleSessionIndex[index].add(session);
            session.setAttribute(WRITE_IDLE_INDEX, index);
        }
    }