Package net.sf.colossus.client
Class ClientThread
java.lang.Object
java.lang.Thread
net.sf.colossus.client.ClientThread
- All Implemented Interfaces:
Runnable
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
Nested ClassesNested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Client
private boolean
private static final ClientThread.ServerEvent
private final boolean
private static final Logger
private final LinkedBlockingQueue<ClientThread.ServerEvent>
private final int
private static int
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
private void
callMethod
(String method, List<String> args) void
void
void
static long
getNow()
int
int
private static int
void
void
notifyUserIfGameIsPaused
(String message) private BattleHex
resolveBattleHex
(String hexLabel) private CreatureType
resolveCreatureType
(String creatureName) private List<CreatureType>
resolveCreatureTypes
(String nameList) private MasterHex
resolveHex
(String label) private Legion
resolveLegion
(String markerId) void
run()
void
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
Field Details
-
LOGGER
-
threadNumberCounter
private static int threadNumberCounter -
threadNr
private final int threadNr -
client
-
queue
-
done
private boolean done -
LOG_PROCESSING_TIMES
private final boolean LOG_PROCESSING_TIMES- See Also:
-
END_EVENT
-
-
Constructor Details
-
ClientThread
-
-
Method Details
-
nextThreadNumber
private static int nextThreadNumber() -
getThreadNumber
public int getThreadNumber() -
enqueue
-
getQueueLen
public int getQueueLen() -
disposeQueue
public void disposeQueue() -
disposeClient
public void disposeClient() -
setClosedByServer
public void setClosedByServer() -
getNameMaybe
-
run
public void run() -
notifyUserIfGameIsPaused
-
notifyThatNotConnected
public void notifyThatNotConnected() -
appendToConnectionLog
-
callMethod
-
resolveHex
-
resolveBattleHex
-
resolveCreatureTypes
-
resolveCreatureType
-
resolveLegion
-
getNow
public static long getNow()
-