org.jogre.client
Class ClientConnectionThread

java.lang.Object
  extended byjava.lang.Thread
      extended byorg.jogre.common.AbstractConnectionThread
          extended byorg.jogre.client.ClientConnectionThread
All Implemented Interfaces:
Runnable

public 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.2.1
Author:
Bob Marks

Field Summary
protected  IClient clientInterface
          Interface betweem this thread and the Frame
protected  String gameID
          Current game ID.
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
connected, in, loop, out, socket, username
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
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(XMLElement message)
          Parse method which reads the first token of the message and calls the appropriate method.
 void send(CommBaseMessage message)
          Send a ITransmittable object from a client to the server.
 void send(CommGameMessage message)
          Send a ITransmittable object from a client to the server.
 void setGameID(String gameID)
          Method for setting the game ID so that the user doesn't need to specify this ever time he creates a comm game message.
 void setTableList(TableList tableList)
          Update the table list.
 void setUserList(UserList userList)
          Update the user list.
 
Methods inherited from class org.jogre.common.AbstractConnectionThread
connect, getSocket, getUsername, run, send, setUsername, stopLoop
 
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
 

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.


gameID

protected String gameID
Current game ID.

Constructor Detail

ClientConnectionThread

public 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(XMLElement message)
Parse method which reads the first token of the message and calls the appropriate method.

Specified by:
parse in class AbstractConnectionThread
Parameters:
message - Communication as an XML object.
See Also:
AbstractConnectionThread.parse(nanoxml.XMLElement)

send

public void send(CommBaseMessage message)
Send a ITransmittable object from a client to the server.

Parameters:
message -

send

public void send(CommGameMessage message)
Send a ITransmittable object from a client to the server.

Parameters:
message -

setGameID

public void setGameID(String gameID)
Method for setting the game ID so that the user doesn't need to specify this ever time he creates a comm game message.

Parameters:
gameID -

getUserList

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

Returns:
List of users.

setUserList

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

Parameters:
userList - List of users

getTableList

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

Returns:
TableList object (contains number of Table objects).

setTableList

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

Parameters:
tableList - TableList object containing Table objects.

disconnect

protected void disconnect()
Stop the thread.


cleanup

public void cleanup()
Client has exitted so clean everything up.

Specified by:
cleanup in class AbstractConnectionThread
See Also:
AbstractConnectionThread.cleanup()