Class SocketClientThread
java.lang.Object
java.lang.Thread
net.sf.colossus.client.SocketClientThread
- All Implemented Interfaces:
Runnable, IServerConnection, IServer
Thread to handle server connection on client side.
- Author:
- David Ripton
-
Nested Class Summary
Nested classes/interfaces inherited from class Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate ClientThreadprivate ClientThreadprivate booleanprivate StringThose are stored at the moment only to be able to reconnectprivate BufferedReaderprivate Stringprivate final booleanprivate booleanprivate final Objectprivate static final Loggerprivate PrintWriterprivate intprivate Stringprivate intprivate Collection<String> private Stringprivate booleanprivate booleanprivate static final Stringprivate booleanprivate Socketprivate booleanprivate StringFields inherited from class Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITYFields inherited from interface IServer
CLIENT_VERSION, CLIENT_VERSION_CAN_HANDLE_NAK, CLIENT_VERSION_CAN_RECONNECT, CLIENT_VERSION_UNDERSTANDS_PING, CLIENT_VERSION_VARIANT_XML_OK, MINIMUM_CLIENT_VERSION -
Constructor Summary
ConstructorsConstructorDescriptionSocketClientThread(String host, int port, String initialName, boolean isRemote, boolean spectator) -
Method Summary
Modifier and TypeMethodDescriptionintvoidacquireAngel(Legion legion, CreatureType angelType) voidvoidapplyCarries(BattleHex hex) voidassignColor(PlayerColor color) voidassignFirstMarker(String markerId) voidassignStrikePenalty(String prompt) private voidcallMethod(String method, List<String> args) voidprivate voidvoidvoidstatic SocketClientThreadcreateConnection(String host, int port, String initialName, boolean remote, boolean spectator) voiddoBattleMove(int tag, BattleHex hex) voiddoMove(Legion legion, MasterHex hex, EntrySide entrySide, boolean teleport, CreatureType teleportingLord) voidvoidvoidvoidvoidvoidvoiddoNotConcede(Legion legion) voidvoiddoRecruit(Recruitment event) voiddoSplit(Legion parent, String childMarker, List<CreatureType> creaturesToSplit) Executes a split of certain creatures from a legion.voidHandles a summon eventvoidvoidvoidvoidintprivate StringvoidbooleanvoidvoidvoidvoidmakeProposal(String proposalString) voidmulligan()voidnewGame()private voidprivate voidprivate Stringprotected static SocketClientThreadrecreateConnection(IServerConnection prevConnection) voidprivate voidvoidrequestSyncDelta(int msgNr, int syncCounter) voidrun()voidvoidprivate voidsendToServer(String message) voidprivate voidsetWaiting(boolean val) private voidvoidvoidstopGame()voidstopSocketClientThread(boolean sendConnect) Client originates the dispose: If done because all is over, player chose close etc, send also a disconnect so that server knows client is "gone".voidvoidundoBattleMove(BattleHex hex) voidvoidundoRecruit(Legion legion) voidvoidupdatePlayerName(String playerName) private Stringprivate Stringvoidprivate StringvoidvoidMethods inherited from class Thread
activeCount, checkAccess, clone, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, threadId, toString, yield
-
Field Details
-
LOGGER
-
clientThread
-
disposedClientThread
-
socket
-
in
-
out
-
goingDown
private boolean goingDown -
selfInterrupted
private boolean selfInterrupted -
serverReceiveTimedout
private boolean serverReceiveTimedout -
host
Those are stored at the moment only to be able to reconnect -
port
private int port -
playerName
-
remote
private boolean remote -
spectator
private boolean spectator -
internalSpectator
private final boolean internalSpectator -
sep
- See Also:
-
reasonFail
-
initialLine
-
variantNameForInit
-
preliminaryPlayerNames
-
isWaitingLock
-
isWaiting
private boolean isWaiting -
ownMessageCounter
private int ownMessageCounter -
abandoned
private boolean abandoned
-
-
Constructor Details
-
SocketClientThread
-
-
Method Details
-
createConnection
public static SocketClientThread createConnection(String host, int port, String initialName, boolean remote, boolean spectator) throws Client.ConnectionInitException - Throws:
Client.ConnectionInitException
-
recreateConnection
protected static SocketClientThread recreateConnection(IServerConnection prevConnection) throws Client.ConnectionInitException - Throws:
Client.ConnectionInitException
-
readOneLine
- Throws:
IOException
-
waitForPrompt
-
waitForSignonOk
- Throws:
IOException
-
waitForGameInfo
- Throws:
IOException
-
getReasonFail
- Specified by:
getReasonFailin interfaceIServerConnection
-
appendToConnectionLog
-
getVariantNameForInit
- Specified by:
getVariantNameForInitin interfaceIServerConnection
-
getPreliminaryPlayerNames
- Specified by:
getPreliminaryPlayerNamesin interfaceIServerConnection
-
getIServer
- Specified by:
getIServerin interfaceIServerConnection
-
setClient
- Specified by:
setClientin interfaceIServerConnection
-
getDisposedQueueLen
public int getDisposedQueueLen()- Specified by:
getDisposedQueueLenin interfaceIServerConnection
-
startThread
public void startThread()- Specified by:
startThreadin interfaceIServerConnection
-
run
-
readAndParseUntilDone
private void readAndParseUntilDone() -
setWaiting
private void setWaiting(boolean val) -
waitForLine
-
isAlreadyDown
public boolean isAlreadyDown()- Specified by:
isAlreadyDownin interfaceIServerConnection
-
cleanupSocket
private void cleanupSocket() -
interrupt
-
stopSocketClientThread
public void stopSocketClientThread(boolean sendConnect) Client originates the dispose: If done because all is over, player chose close etc, send also a disconnect so that server knows client is "gone". If done because of actually or suspected "connection dead/problems", just shut down the SCT peacefully, do not inform server, client might want to reconnect later with a new SCT / ClientThread pair.- Specified by:
stopSocketClientThreadin interfaceIServerConnection- Parameters:
sendConnect- If true, sends a disconnect message to server
-
abandonAndGetMessageCounter
public int abandonAndGetMessageCounter()- Specified by:
abandonAndGetMessageCounterin interfaceIServerConnection
-
parseLine
-
callMethod
-
getPrintName
-
sendToServer
-
signOn
-
requestGameInfo
private void requestGameInfo() -
updatePlayerName
- Specified by:
updatePlayerNamein interfaceIServerConnection
-
leaveCarryMode
public void leaveCarryMode()- Specified by:
leaveCarryModein interfaceIServer
-
doneWithBattleMoves
public void doneWithBattleMoves()- Specified by:
doneWithBattleMovesin interfaceIServer
-
doneWithStrikes
public void doneWithStrikes()- Specified by:
doneWithStrikesin interfaceIServer
-
acquireAngel
- Specified by:
acquireAngelin interfaceIServer
-
doSummon
-
doRecruit
-
engage
-
concede
-
doNotConcede
- Specified by:
doNotConcedein interfaceIServer
-
flee
-
doNotFlee
-
makeProposal
- Specified by:
makeProposalin interfaceIServer
-
fight
-
doBattleMove
- Specified by:
doBattleMovein interfaceIServer
-
strike
-
applyCarries
- Specified by:
applyCarriesin interfaceIServer
-
undoBattleMove
- Specified by:
undoBattleMovein interfaceIServer
-
assignStrikePenalty
- Specified by:
assignStrikePenaltyin interfaceIServer
-
mulligan
-
undoSplit
-
undoMove
-
undoRecruit
- Specified by:
undoRecruitin interfaceIServer
-
doneWithSplits
public void doneWithSplits()- Specified by:
doneWithSplitsin interfaceIServer
-
doneWithMoves
public void doneWithMoves()- Specified by:
doneWithMovesin interfaceIServer
-
doneWithEngagements
public void doneWithEngagements()- Specified by:
doneWithEngagementsin interfaceIServer
-
doneWithRecruits
public void doneWithRecruits()- Specified by:
doneWithRecruitsin interfaceIServer
-
withdrawFromGame
public void withdrawFromGame()- Specified by:
withdrawFromGamein interfaceIServer
-
sendDisconnect
public void sendDisconnect()- Specified by:
sendDisconnectin interfaceIServer
-
stopGame
-
doSplit
Description copied from interface:IServerExecutes a split of certain creatures from a legion. -
doMove
-
assignColor
- Specified by:
assignColorin interfaceIServer
-
assignFirstMarker
- Specified by:
assignFirstMarkerin interfaceIServer
-
newGame
-
loadGame
-
saveGame
-
checkServerConnection
public void checkServerConnection()- Specified by:
checkServerConnectionin interfaceIServer
-
clientConfirmedCatchup
public void clientConfirmedCatchup()- Specified by:
clientConfirmedCatchupin interfaceIServer
-
joinGame
-
watchGame
-
requestSyncDelta
public void requestSyncDelta(int msgNr, int syncCounter) - Specified by:
requestSyncDeltain interfaceIServerConnection
-
replyToPing
public void replyToPing() -
enforcedConnectionException
public void enforcedConnectionException()- Specified by:
enforcedConnectionExceptionin interfaceIServerConnection
-