org.jogre.client
Class ClientConnectionThread

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

public abstract class ClientConnectionThread
extends AbstractConnectionThread

Client connection which is spawned from the client machine and receives/ sends communication to/from the server. This class also holds a mirrored copy of the TableList and UserList objects which are stored on the JogreServer.

The communication between this connection thread and the GUI (e.g. an implementation of the JogreClientFrame) must goes through an interface IClient to ensure maximum abstraction.

Version:
Alpha 0.1
Author:
Bob Marks

Field Summary
protected  IClient clientInterface
          Interface betweem this thread and the Frame
protected  TableList tableList
          TableList object which should mirror that on the JogreServer.
protected  UserList userList
          UserList object which should mirror that on the JogreServer.
 
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
protected ClientConnectionThread(Socket connection, String username, IClient clientInterface)
          Default constructor which takes a Socket connection to the server, a username and an IClient which sits between this class and the GUI.
 
Method Summary
 void cleanup()
          Client has exitted so clean everything up.
protected  void disconnect()
          Stop the thread.
 TableList getTableList()
          Return the table list object (should be the same as the server table list).
 UserList getUserList()
          Return the user list (should be the same as the server user list object).
 void parse(String messageType, String inString)
          Parse method which reads the first token of the message and calls the appropriate method.
protected  void receiveTableMessage(String inString)
          Receive table message.
protected  void recieveConnect(String inString)
          Inform client about the connection.
protected  void recieveGameOver(String inString)
           
protected  void recieveInvite(String inString)
          Receive invite from the user.
protected  void recieveMessageBroadcast(String inString)
          Receive message broad from the server.
protected  void recieveMessageBroadCastRoom(String inString)
          Recieve a message broadcast to room.
protected  void recieveMessagePrivate(String inString)
          Receive a private message.
protected  void recieveTable(String inString)
          Recieve a single table from the server.
protected  void recieveTableList(String inString)
          Receive table list from the server.
protected  void recieveUserList(String inString)
           
 void setTableList(TableList tableList)
          Update the table list.
 void setUserList(UserList userList)
          Update the user list.
 
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

clientInterface

protected IClient clientInterface
Interface betweem this thread and the Frame

userList

protected UserList userList
UserList object which should mirror that on the JogreServer.

tableList

protected TableList tableList
TableList object which should mirror that on the JogreServer.
Constructor Detail

ClientConnectionThread

protected ClientConnectionThread(Socket connection,
                                 String username,
                                 IClient clientInterface)
Default constructor which takes a Socket connection to the server, a username and an IClient which sits between this class and the GUI.
Parameters:
connection - Socket connection to server.
username - Username
clientInterface - Interface between this class and GUI.
Method Detail

parse

public void parse(String messageType,
                  String inString)
Parse method which reads the first token of the message and calls the appropriate method.
Overrides:
parse in class AbstractConnectionThread
See Also:
AbstractConnectionThread.parse(java.lang.String, java.lang.String)

getUserList

public UserList getUserList()
Return the user list (should be the same as the server user list object).
Returns:
 

setUserList

public void setUserList(UserList userList)
Update the user list.
Parameters:
userList -  

getTableList

public TableList getTableList()
Return the table list object (should be the same as the server table list).
Returns:
 

setTableList

public void setTableList(TableList tableList)
Update the table list.
Parameters:
tableList -  

disconnect

protected void disconnect()
Stop the thread.

cleanup

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

recieveConnect

protected void recieveConnect(String inString)
                       throws TransmissionException
Inform client about the connection.
Parameters:
inString - Unparsed String.
Throws:
TransmissionException - Thrown if there is a transmission error.

recieveInvite

protected void recieveInvite(String inString)
                      throws TransmissionException
Receive invite from the user.
Parameters:
inString - Unparsed String.
Throws:
TransmissionException - Thrown if there is a transmission error.

recieveGameOver

protected void recieveGameOver(String inString)
                        throws TransmissionException

recieveUserList

protected void recieveUserList(String inString)
                        throws TransmissionException
Parameters:
inString -  
Throws:
TransmissionException -  

recieveTableList

protected void recieveTableList(String inString)
                         throws TransmissionException
Receive table list from the server.
Parameters:
inString -  
Throws:
TransmissionException -  

recieveTable

protected void recieveTable(String inString)
                     throws TransmissionException
Recieve a single table from the server.
Parameters:
inString -  
Throws:
TransmissionException -  

recieveMessageBroadcast

protected void recieveMessageBroadcast(String inString)
                                throws TransmissionException
Receive message broad from the server.
Parameters:
inString -  
Throws:
TransmissionException -  

recieveMessagePrivate

protected void recieveMessagePrivate(String inString)
                              throws TransmissionException
Receive a private message.
Parameters:
inString -  
Throws:
TransmissionException -  

receiveTableMessage

protected void receiveTableMessage(String inString)
                            throws TransmissionException
Receive table message.
Parameters:
inString -  
Throws:
TransmissionException - Thrown if there is a transmission error.

recieveMessageBroadCastRoom

protected void recieveMessageBroadCastRoom(String inString)
                                    throws TransmissionException
Recieve a message broadcast to room.
Parameters:
inString -  
Throws:
TransmissionException -