com.objectwave.simpleSockets
Class WatchdogServer
java.lang.Object
|
+--com.objectwave.simpleSockets.SimpleServer
|
+--com.objectwave.simpleSockets.WatchdogServer
- All Implemented Interfaces:
- java.lang.Runnable
- Direct Known Subclasses:
- MutexServer
- public class WatchdogServer
- extends SimpleServer
A Watchdog server to watch for unexpected client deaths. Clients register
by opening a socket with the server. If the client's socket closes without
the client saying goodbye, then the clientDied(long id) method is called.
if the client said goodbye and *then* the socket closed, then the
clientLeft(long id) method is called. Override these methods to provide
your own behaviour in these events. Note that there's also a threadsafe
vector accessed via addClient(long), removeClient(long), and isClient(long).
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
WatchdogServer
public WatchdogServer()
WatchdogServer
public WatchdogServer(int port)
addClient
public void addClient(long id)
clientDied
protected void clientDied(long id)
clientLeft
protected void clientLeft(long id)
getClientServer
public ServeClient getClientServer(SimpleServer svr,
int count,
java.lang.Thread thread)
- Override this method if you don't want to do anything special with the
handling of clients. Just return your ServerClient object.
- Overrides:
getClientServer
in class SimpleServer
- Parameters:
svr
- count
- thread
-
- Returns:
- The ClientServer value
getDefaultPort
public static final int getDefaultPort()
isClient
public boolean isClient(long id)
main
public static void main(java.lang.String[] args)
- This method should be overriden to create an instance
of your SimpleServer. It should look the same xcept it should
Specify new .startServer();
- Parameters:
args
-
newClient
protected void newClient(long id)
processGoodbye
protected void processGoodbye(long id)
processMessage
protected java.lang.String processMessage(long id,
java.lang.String message)
removeClient
protected boolean removeClient(long id)