net.sf.colossus.client
Class ClientThread

java.lang.Object
  extended by java.lang.Thread
      extended by net.sf.colossus.client.ClientThread
All Implemented Interfaces:
java.lang.Runnable

public class ClientThread
extends java.lang.Thread

This will be a thread that executes all the client side processing; additional to the actual SocketClientThread which did that earlier. SCT will only handle the reading from Socket and push incoming messages to a queue and return back to listening on the socket. This way, it should be able to read all data in time so that no data pile up, and reply to ping requests almost instantly. ClientThread gets most of messages to parse already via a queue. Should also sending use a queue, and/or, the sending methods be inside ClientThread, and SocketClientThread merely provide the sendToServer method (which could be implemented differently e.g. in a "send via queue, instead of via socket", for local clients)?

Author:
Clemens Katzer

Nested Class Summary
static class ClientThread.ServerEvent
           
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private  Client client
           
private  boolean done
           
private static ClientThread.ServerEvent END_EVENT
           
private  boolean LOG_PROCESSING_TIMES
           
private static java.util.logging.Logger LOGGER
           
private  java.util.concurrent.LinkedBlockingQueue<ClientThread.ServerEvent> queue
           
private  int threadNr
           
private static int threadNumberCounter
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ClientThread(Client client)
           
 
Method Summary
 void appendToConnectionLog(java.lang.String s)
           
private  void callMethod(java.lang.String method, java.util.List<java.lang.String> args)
           
 void disposeClient()
           
 void disposeQueue()
           
 void enqueue(java.lang.String method, java.util.List<java.lang.String> args)
           
 java.lang.String getNameMaybe()
           
static long getNow()
           
 int getQueueLen()
           
 int getThreadNumber()
           
private static int nextThreadNumber()
           
 void notifyThatNotConnected()
           
 void notifyUserIfGameIsPaused(java.lang.String message)
           
private  BattleHex resolveBattleHex(java.lang.String hexLabel)
           
private  CreatureType resolveCreatureType(java.lang.String creatureName)
           
private  java.util.List<CreatureType> resolveCreatureTypes(java.lang.String nameList)
           
private  MasterHex resolveHex(java.lang.String label)
           
private  Legion resolveLegion(java.lang.String markerId)
           
 void run()
           
 void setClosedByServer()
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, 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

LOGGER

private static final java.util.logging.Logger LOGGER

threadNumberCounter

private static int threadNumberCounter

threadNr

private final int threadNr

client

private final Client client

queue

private final java.util.concurrent.LinkedBlockingQueue<ClientThread.ServerEvent> queue

done

private boolean done

LOG_PROCESSING_TIMES

private final boolean LOG_PROCESSING_TIMES
See Also:
Constant Field Values

END_EVENT

private static final ClientThread.ServerEvent END_EVENT
Constructor Detail

ClientThread

public ClientThread(Client client)
Method Detail

nextThreadNumber

private static int nextThreadNumber()

getThreadNumber

public int getThreadNumber()

enqueue

public void enqueue(java.lang.String method,
                    java.util.List<java.lang.String> args)

getQueueLen

public int getQueueLen()

disposeQueue

public void disposeQueue()

disposeClient

public void disposeClient()

setClosedByServer

public void setClosedByServer()

getNameMaybe

public java.lang.String getNameMaybe()

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

notifyUserIfGameIsPaused

public void notifyUserIfGameIsPaused(java.lang.String message)

notifyThatNotConnected

public void notifyThatNotConnected()

appendToConnectionLog

public void appendToConnectionLog(java.lang.String s)

callMethod

private void callMethod(java.lang.String method,
                        java.util.List<java.lang.String> args)

resolveHex

private MasterHex resolveHex(java.lang.String label)

resolveBattleHex

private BattleHex resolveBattleHex(java.lang.String hexLabel)

resolveCreatureTypes

private java.util.List<CreatureType> resolveCreatureTypes(java.lang.String nameList)

resolveCreatureType

private CreatureType resolveCreatureType(java.lang.String creatureName)

resolveLegion

private Legion resolveLegion(java.lang.String markerId)

getNow

public static long getNow()