keepalive.keepalive
Class HeartbeatServer

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--keepalive.keepalive.KeepAlive
              |
              +--keepalive.keepalive.HeartbeatServer
All Implemented Interfaces:
MessageListener, java.lang.Runnable

public class HeartbeatServer
extends KeepAlive
implements MessageListener

Echoes the "heartbeat" which is sent regularly by HeartbeatClient, closing the socket if there is silence for a suspicious time period.
Combines PassiveKeepAlive (listens for suspicious silence in incoming data) and IHearYou (responds to AreYouThere). Unlike PassiveKeepAlive, but like AreYouThere, it will automatically close the socket when the timeout period passes with no incoming data.

See Also:
HeartbeatClient

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
HeartbeatServer()
          Used for dynamic classloading.
HeartbeatServer(Receiver receiver, Sender sender)
          This is the server.
 
Method Summary
 boolean messageReceived(java.lang.String s)
          This method is called by Receiver as the call-back method from MessageListener Ignore all messages but "Are You There." Respond to Are-You-There with "I Hear You." There is an alternate implementation, not as simple but more conservative of bandwidth, which resembles somewhat the AreYouThere/IHearYou pair.
 void run()
          Require the subclasses to implement run(), to prevent them from using the run() method in class Thread with a null body.
 void setReceiver(Receiver receiver)
          Set the receiver object which receives messages that arrive at the socket associated with this Keep-Alive.
 
Methods inherited from class keepalive.keepalive.KeepAlive
end, endRequested, getDummyString, getReceiver, getSender, getSilentTimeForIncoming, 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

HeartbeatServer

public HeartbeatServer(Receiver receiver,
                       Sender sender)
This is the server.
Parameters:
sender -  

HeartbeatServer

public HeartbeatServer()
Used for dynamic classloading.
Method Detail

setReceiver

public void setReceiver(Receiver receiver)
Set the receiver object which receives messages that arrive at the socket associated with this Keep-Alive.
Overrides:
setReceiver in class KeepAlive
Parameters:
receiver -  

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

messageReceived

public boolean messageReceived(java.lang.String s)
This method is called by Receiver as the call-back method from MessageListener Ignore all messages but "Are You There." Respond to Are-You-There with "I Hear You." There is an alternate implementation, not as simple but more conservative of bandwidth, which resembles somewhat the AreYouThere/IHearYou pair.
Specified by:
messageReceived in interface MessageListener
Following copied from interface: keepalive.communication.MessageListener
Parameters:
s - the message that was received
Returns:
true if this MessageListener processed the incoming message, false if it ignored it.


© 2000 Joshua Fox