org.jogre.server
Class ServerConnectionThread

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--org.jogre.common.AbstractConnectionThread
              |
              +--org.jogre.server.ServerConnectionThread
All Implemented Interfaces:
Runnable

public abstract class ServerConnectionThread
extends AbstractConnectionThread

Every time a client connections to a JogreServer this class (which extends Thread) is run. This ensures that a JogreServer is multi-thread.

Version:
Alpha 0.1
Author:
Bob Marks
See Also:
JogreServer

Field Summary
protected  ConnectionList connections
          Convience link to the userList field in the JogreServer object.
protected  JogreServer server
          link to the JogreServer
protected  TableList tableList
          Convience link to the tableList field in the JogreServer object.
protected  UserList userList
          Convience link to the userList field in the JogreServer object.
 
Fields inherited from class org.jogre.common.AbstractConnectionThread
in, loop, out, socket, username
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ServerConnectionThread(Socket clientSocket, JogreServer server)
          Constructor which takes a socket connection and a link to the server.
 
Method Summary
 void broadcast(ITransmittable transmittableObject)
          Broadcast a transmittable object to all the clients.
 void broadcast(String message)
          Broadcast a message to all clients.
 void broadcast(String omitUser, String message)
          Broadcasts a message to all users except the person who sent the message.
 void cleanup()
          Client has exitted so clean everything up.
 void parse(String messageType, String inString)
          Implementation of the parse method.
 void transmit(String username, ITransmittable transObject)
          Overloaded version which takes a ITransmittable object.
 void transmit(String username, String message)
          This little helper method sends an object to the two players in a game.
 void transmitToTable(int tableNum, ITransmittable transObject)
          Transmit a message to the specified table.
 void transmitToTable(String omitUser, int tableNum, ITransmittable transObject)
          Transmit a messgae to a table but omit a user (this user will generally be the player who has created the message in the first place).
 
Methods inherited from class org.jogre.common.AbstractConnectionThread
getReader, getSocket, getUsername, run, send, send
 
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
 

Field Detail

server

protected JogreServer server
link to the JogreServer

userList

protected UserList userList
Convience link to the userList field in the JogreServer object.

tableList

protected TableList tableList
Convience link to the tableList field in the JogreServer object.

connections

protected ConnectionList connections
Convience link to the userList field in the JogreServer object.
Constructor Detail

ServerConnectionThread

public ServerConnectionThread(Socket clientSocket,
                              JogreServer server)
Constructor which takes a socket connection and a link to the server.
Parameters:
clientSocket -  
server -  
Method Detail

parse

public void parse(String messageType,
                  String inString)
           throws TransmissionException
Implementation of the parse method. The first parameter is the first token of a ITransmittable object. This token is generally stored in the Comm interface or as a static constant field in the ITransmittable object.
Overrides:
parse in class AbstractConnectionThread
See Also:
AbstractConnectionThread.parse(java.lang.String, java.lang.String)

cleanup

public void cleanup()
Client has exitted so clean everything up.
Overrides:
cleanup in class AbstractConnectionThread
See Also:
AbstractConnectionThread.cleanup()

transmit

public void transmit(String username,
                     String message)
This little helper method sends an object to the two players in a game.
Parameters:
username - Username of the client.
message - Message as a String.

transmitToTable

public void transmitToTable(int tableNum,
                            ITransmittable transObject)
Transmit a message to the specified table.
Parameters:
tableNum -  
transObject -  

transmitToTable

public void transmitToTable(String omitUser,
                            int tableNum,
                            ITransmittable transObject)
Transmit a messgae to a table but omit a user (this user will generally be the player who has created the message in the first place).
Parameters:
omitUser - Username to omit from the list (usually the sender).
tableNum - Table number to transmit message to.
transObject - Object which implements the ITransmittable interface.

broadcast

public void broadcast(String message)
Broadcast a message to all clients.
Parameters:
message -  

broadcast

public void broadcast(ITransmittable transmittableObject)
Broadcast a transmittable object to all the clients.
Parameters:
transmittableObject -  

broadcast

public void broadcast(String omitUser,
                      String message)
Broadcasts a message to all users except the person who sent the message.
Parameters:
omitUser - User to omit.
message - Message as a String.

transmit

public void transmit(String username,
                     ITransmittable transObject)
Overloaded version which takes a ITransmittable object.
Parameters:
username - Username to send message to.
transObject - Transmittable object.