keepalive.keepalive
Class HeartbeatClient

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--keepalive.keepalive.KeepAlive
              |
              +--keepalive.keepalive.HeartbeatClient
All Implemented Interfaces:
java.lang.Runnable

public class HeartbeatClient
extends KeepAlive

Sends a "heartbeat" which is echoed by HeartbeatServer, closing the socket if there is silence for a suspicious time period.
Combines ActiveKeepAlive (periodically sends a message) with PassiveKeepAlive (listens for suspicious silence in incoming data) and AreYouThere (expects a response to its messages). Unlike PassiveKeepAlive, but like AreYouThere it will automatically close the socket when the timeout period passes with no incoming data.
For an alternate implementation, not as simple but more conservative of bandwidth, see the JavaDocs for HeartbeatServer messageReceived(String s)

See Also:
HeartbeatServer.messageReceived(String s)

Fields inherited from class keepalive.keepalive.KeepAlive
ARE_YOU_THERE, endRequested, I_HEAR_YOU, TIME_BETWEEN_ACTIVE_PROBES
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
HeartbeatClient()
          Create a new Keep-Alive.
HeartbeatClient(Receiver receiver, Sender sender)
          Create a new Keep-Alive.
 
Method Summary
 void run()
          Require the subclasses to implement run(), to prevent them from using the run() method in class Thread with a null body.
 
Methods inherited from class keepalive.keepalive.KeepAlive
end, endRequested, getDummyString, getReceiver, getSender, getSilentTimeForIncoming, setReceiver, setSender
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HeartbeatClient

public HeartbeatClient(Receiver receiver,
                       Sender sender)
Create a new Keep-Alive.
Parameters:
receiver -  
sender -  

HeartbeatClient

public HeartbeatClient()
Create a new Keep-Alive. Used for dynamic classloading.
Method Detail

run

public void run()
Description copied from class: KeepAlive
Require the subclasses to implement run(), to prevent them from using the run() method in class Thread with a null body.
Overrides:
run in class KeepAlive


© 2000 Joshua Fox