com.sun.slamd.server
Class StatClientConnection

java.lang.Object
  extended byjava.lang.Thread
      extended bycom.sun.slamd.server.StatClientConnection
All Implemented Interfaces:
java.lang.Runnable

public class StatClientConnection
extends java.lang.Thread

This class defines a thread that is spawned by the server to handle each stat client connection. It takes care of reading messages in from the client and provides methods for sending messages to the client.


Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
StatClientConnection(SLAMDServer slamdServer, StatListener listener, java.net.Socket clientSocket)
          Creates a new stat client connection based on the provided information.
 
Method Summary
 java.lang.String getClientID()
          Retrieves the client ID associated with this stat client connection.
 java.lang.String getClientIPAddress()
          Retrieves the IP address of the client system associated with this connection.
 java.lang.String getClientVersion()
          Retrieves the version of the client software that the client system is running.
 Message getMessage(int messageID)
          Retrieves the message with the specified message ID from the receive queue.
 void run()
          Listens for messages from the client and either handles them or hands them off to be handled elsewhere.
 void sendServerShutdownMessage(boolean closeSocket)
          Sends a message to the client that indicates the server is shutting down, and then optionally closes the connection to the client.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, 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

StatClientConnection

public StatClientConnection(SLAMDServer slamdServer,
                            StatListener listener,
                            java.net.Socket clientSocket)
                     throws SLAMDException
Creates a new stat client connection based on the provided information.

Parameters:
slamdServer - The SLAMD server with which this client is associated.
listener - The listener that accepted this connection.
clientSocket - The socket used to communicate with the client.
Throws:
SLAMDException - If a problem occurs while creating the connection.
Method Detail

getClientID

public java.lang.String getClientID()
Retrieves the client ID associated with this stat client connection.

Returns:
The client ID associated with this stat client connection.

getClientIPAddress

public java.lang.String getClientIPAddress()
Retrieves the IP address of the client system associated with this connection.

Returns:
The IP address of the client system associated with this connection.

getClientVersion

public java.lang.String getClientVersion()
Retrieves the version of the client software that the client system is running.

Returns:
The version of the client software that the client system is running.

getMessage

public Message getMessage(int messageID)
Retrieves the message with the specified message ID from the receive queue.

Parameters:
messageID - The message ID of the message to retrieve.
Returns:
The requested message, or null if an appropriate response does not arrive within an appropriate timeout period.

sendServerShutdownMessage

public void sendServerShutdownMessage(boolean closeSocket)
Sends a message to the client that indicates the server is shutting down, and then optionally closes the connection to the client.

Parameters:
closeSocket - Indicates whether the connection to the client should be closed.

run

public void run()
Listens for messages from the client and either handles them or hands them off to be handled elsewhere.