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

Field Summary
protected  IClient clientInterface
          Interface betweem this thread and the Frame
protected  Game game
          Game associated with this connection thread (will be mirrored to that on the server.
protected  String gameID
          Current game ID.
 
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.
 Game getGame()
          Return the game object which should be mirrored to that on the server.
 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 delegate to the implementating client.
 void send(CommGameMessage message)
          Send a ITransmittable object from a client to the server.
 void setClientInterface(IClient clientInterface)
          Set the client interface.
 void setGame(Game game)
          Set the game object from the server.
 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, setSocket, 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


gameID

protected String gameID
Current game ID.


game

protected Game game
Game associated with this connection thread (will be mirrored to that on the server.

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

setClientInterface

public void setClientInterface(IClient clientInterface)
Set the client interface.

Parameters:
clientInterface - Client interface

parse

public void parse(XMLElement message)
Parse method which reads the first token of the message and delegate to the implementating client.

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

send

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

Parameters:
message -

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

getGame

public Game getGame()
Return the game object which should be mirrored to that on the server.

Returns:
Game object consisting of user and table lists.

setGame

public void setGame(Game game)
Set the game object from the server.

Parameters:
game -

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()