spellcast.server
Class ServerStatusRequestHandler

java.lang.Object
  extended by spellcast.server.ServerStatusRequestHandler
All Implemented Interfaces:
java.lang.Runnable, NetConstants

public class ServerStatusRequestHandler
extends java.lang.Object
implements NetConstants, java.lang.Runnable

The ServerStatusRequestHandler listens for ServerStatusRequest messages and handles them. The class creates the datagram socket that is used to receive the broadcast messages for ServerStatusRequests and creates the ServerStatusResponse message. A new thread is started to handle the message processing for ServerStatusRequestHandler when start is called. Call stop to stop the thread.

Author:
Barrie Treloar

Field Summary
 
Fields inherited from interface spellcast.net.NetConstants
SPELLCAST_NET_BROADCAST_INETADDRESS, SPELLCAST_NET_DEFAULT_PORT, SPELLCAST_NET_SERVERLIST_PORT
 
Constructor Summary
ServerStatusRequestHandler()
           
 
Method Summary
 void run()
          This thread will start running when start is called and continue running until the stop method is called.
 void start()
          Allocate resources, create and start the thread.
 void stop()
          Sets the isRunning flag to false which lets run exit the infite loop.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServerStatusRequestHandler

public ServerStatusRequestHandler()
Method Detail

run

public void run()
This thread will start running when start is called and continue running until the stop method is called. This method loops while checking for a ServerStatusRequest message to be received. When it is received it queries the current game for its status returns the status in a ServerStatusResponse message.

Specified by:
run in interface java.lang.Runnable

start

public void start()
           throws ServerException
Allocate resources, create and start the thread. Resources are deallocated in cleanup.

Throws:
ServerException - thrown if the server status socket could not be allocated.

stop

public void stop()
Sets the isRunning flag to false which lets run exit the infite loop. This method will wait until the thread dies before calling cleanup where resources are deallocated.



Copyright © 2001-2005 Spellcast. All Rights Reserved.