com.threerings.util
Class IdleTracker

java.lang.Object
  extended by com.threerings.util.IdleTracker

public abstract class IdleTracker
extends Object

Used to track user idleness in an AWT application.


Nested Class Summary
protected  class IdleTracker.EventListener
           
 
Field Summary
protected  long _lastEvent
          The time of the last mouse or keyboard event; used to track whether the user is idle.
protected  int _state
          Whether the user is currently active, idle or abandoned.
protected  long _toAbandonTime
          The duration after which we declare the user to have abandoned ship.
protected  long _toIdleTime
          The duration after which we declare the user to be idle.
protected static int ABANDONED
           
protected static int ACTIVE
           
protected static long EVENT_MASK
           
protected static int IDLE
           
 
Constructor Summary
IdleTracker(long toIdleTime, long toAbandonTime)
          Creates an idle tracker that will report idleness (via idledOut()) after toIdleTime milliseconds have elapsed.
 
Method Summary
protected abstract  void abandonedShip()
          Called when the client has been idle for _toIdleTime plus _toAbandonTime milliseconds.
protected  void checkIdle()
          Checks the last user event time and posts a command to idle them out if they've been inactive for too long, or log them out if they've been idle for too long.
protected abstract  long getTimeStamp()
          This should return a timestamp.
protected  void handleUserActivity()
          Called with any keyboard or mouse events performed on the frame so as to note user activity as it pertains to tracking the client idle state.
protected abstract  void idledIn()
          Called when the client becomes non-idle after we have previously reported their idleness.
protected abstract  void idledOut()
          Called when the client has been idle for _toIdleTime milliseconds.
 void start(KeyboardManager keymgr, RunQueue rqueue)
           
 void start(KeyboardManager keymgr, Window root, RunQueue rqueue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_toIdleTime

protected long _toIdleTime
The duration after which we declare the user to be idle.


_toAbandonTime

protected long _toAbandonTime
The duration after which we declare the user to have abandoned ship.


_lastEvent

protected long _lastEvent
The time of the last mouse or keyboard event; used to track whether the user is idle.


_state

protected int _state
Whether the user is currently active, idle or abandoned.


ACTIVE

protected static final int ACTIVE
See Also:
Constant Field Values

IDLE

protected static final int IDLE
See Also:
Constant Field Values

ABANDONED

protected static final int ABANDONED
See Also:
Constant Field Values

EVENT_MASK

protected static final long EVENT_MASK
See Also:
Constant Field Values
Constructor Detail

IdleTracker

public IdleTracker(long toIdleTime,
                   long toAbandonTime)
Creates an idle tracker that will report idleness (via idledOut()) after toIdleTime milliseconds have elapsed. After an additional toAbandonTime milliseconds have elapsed, we will report that the user has abandonedShip().

Method Detail

start

public void start(KeyboardManager keymgr,
                  RunQueue rqueue)

start

public void start(KeyboardManager keymgr,
                  Window root,
                  RunQueue rqueue)

idledOut

protected abstract void idledOut()
Called when the client has been idle for _toIdleTime milliseconds.


idledIn

protected abstract void idledIn()
Called when the client becomes non-idle after we have previously reported their idleness.


abandonedShip

protected abstract void abandonedShip()
Called when the client has been idle for _toIdleTime plus _toAbandonTime milliseconds.


getTimeStamp

protected abstract long getTimeStamp()
This should return a timestamp. We would use System.currentTimeMillis() except that on Windows that sometimes does strange things like leap forward in time causing immediate idleness.


handleUserActivity

protected void handleUserActivity()
Called with any keyboard or mouse events performed on the frame so as to note user activity as it pertains to tracking the client idle state.


checkIdle

protected void checkIdle()
Checks the last user event time and posts a command to idle them out if they've been inactive for too long, or log them out if they've been idle for too long.