/**
   * This is periodically called by the JICPMediatorManager and is used by this NIOMediator to
   * evaluate the elapsed time without the need of a dedicated thread or timer.
   */
  public final void tick(long currentTime) {
    if (active && !connectionDropped) {
      // 1) If there is a blocking read operation in place check the
      // response timeout
      inpManager.checkResponseTime(currentTime);

      // 2) Evaluate the keep alive
      if (keepAliveTime > 0) {
        if ((currentTime - lastReceivedTime) > (keepAliveTime + RESPONSE_TIMEOUT)) {
          // Missing keep-alive.
          // The OUT connection is no longer valid
          if (outManager.isConnected()) {
            myLogger.log(Logger.WARNING, myID + ": Missing keep-alive");
            outManager.resetConnection();
          }
          // Check the INP connection. Since this method must return
          // asap, does it in a separated Thread
          if (inpManager.isConnected()) {
            Thread t =
                new Thread() {

                  public void run() {
                    try {
                      // JICPPacket pkt = new JICPPacket(JICPProtocol.KEEP_ALIVE_TYPE,
                      // JICPProtocol.DEFAULT_INFO, null);
                      // inpManager.dispatch(pkt, false);
                      inpManager.sendServerKeepAlive();
                      if (myLogger.isLoggable(Logger.CONFIG)) {
                        myLogger.log(Logger.CONFIG, myID + ": IC valid");
                      }
                    } catch (Exception e) {
                      // Just do nothing: the INP connection has been reset
                    }
                  }
                };
            t.start();
          }
        }
      }

      // 3) Evaluate the max disconnection time
      if (outManager.checkMaxDisconnectionTime(currentTime)) {
        myLogger.log(Logger.SEVERE, myID + ": Max disconnection time expired.");
        // Consider as if the FrontEnd has terminated spontaneously -->
        // Kill the above container (this will also kill this NIOBEDispatcher).
        kill();
      }
    }
  }
 public boolean isConnected() {
   return inpManager.isConnected() && outManager.isConnected();
 }