示例#1
0
  private void resetClientTimer(Socket socket) {
    if (this.idleClientTimer == null) {
      if (log.logTrace()) {
        log.trace("No idle client timeout configured, skipping timer reset");
      }
      return;
    }

    if (log.logTrace()) {
      log.trace("Resetting idle client timer: " + System.identityHashCode(socket));
    }

    // Store this in a local so we don't have to worry about
    // the value changing underneath us.
    long timeout = this.idleClientTimeout;

    // Cancel the existing task for this socket ...
    TimerTask curTask = (TimerTask) this.socketActivity.get(socket);
    if (curTask != null) {
      curTask.cancel();
    }

    // And schedule a new one.
    TimerTask task = new IdleClientTimerTask(socket);
    this.socketActivity.put(socket, task);
    this.idleClientTimer.schedule(task, timeout);
  }
示例#2
0
  protected void deregisterSocket(Socket socket) {
    TimerTask task = (TimerTask) this.socketActivity.remove(socket);
    if (task != null) {
      task.cancel();
    }

    super.deregisterSocket(socket);
  }