final class ClientHandler extends ClientHandlerStub implements IClient
Modifier and Type | Field and Description |
---|---|
(package private) java.nio.ByteBuffer |
bb |
private int |
cantSendMessageRepeated |
private java.nio.charset.Charset |
charset |
private java.lang.String |
CHARSET_NAME |
private int |
clientVersion |
private int |
commitPointCounter |
private java.nio.charset.CharsetDecoder |
decoder |
private static java.lang.String |
DEFAULT_CHAR_SET |
private boolean |
didExplicitDisconnect |
(package private) java.lang.String |
encodedMsg |
private java.nio.charset.CharsetEncoder |
encoder |
boolean |
fakeDisconnect
Debug stuff, only for testing/development purposes
|
private java.lang.String |
incompleteInput |
private java.lang.String |
incompleteText |
private static java.util.logging.Logger |
LOGGER |
private static int |
MAX_KEEP_LINES |
private int |
newCounter |
private boolean |
obsolete |
(package private) int |
previousRetries |
(package private) java.util.LinkedList<java.lang.String> |
queue
The queue in which messages are stored, until they were really written.
|
private java.util.ArrayList<java.lang.String> |
recentlyProcessedLines |
private java.nio.channels.SelectionKey |
selectorKey |
(package private) int |
should |
private java.nio.channels.SocketChannel |
socketChannel |
private boolean |
spectator |
private boolean |
temporarilyDisconnected |
private long |
temporarilyInTrouble |
private boolean |
withdrawnAlready |
(package private) int |
writtenTotal |
counter, isCommitPoint, isGone, messageCounter, playerName, redoQueue, sep, server, signonName
Constructor and Description |
---|
ClientHandler(Server server,
java.nio.channels.SocketChannel channel,
java.nio.channels.SelectionKey selKey) |
Modifier and Type | Method and Description |
---|---|
private void |
attemptWritingToChannel() |
private void |
callMethod(java.lang.String method,
java.util.List<java.lang.String> args)
This is the longish if-elseif-else block which deserialized all
client-to-server calls back from String to actual methodCalls.
|
boolean |
canHandleAdvancedSync() |
boolean |
canHandleBattleMoveNak() |
protected boolean |
canHandleNewVariantXML() |
protected boolean |
canHandlePingRequest() |
void |
clearDisconnectClient() |
void |
clearTemporarilyInTrouble() |
void |
cloneRedoQueue(ClientHandler oldCH) |
protected void |
commitPoint() |
private void |
confirmCommitPoint(int confirmedNr)
Remove the messages in redoQueue prior to given commit point
|
void |
declareObsolete() |
boolean |
didExplicitDisconnect() |
void |
disposeClient()
Server side disposes a client (and informs it about it first)
To be used only for "disposeAllClients()", otherwise setIsGone
reason is misleading.
|
private void |
doCallMethodInTryBlock(java.lang.String line,
java.lang.String method,
java.util.List<java.lang.String> li) |
java.lang.String |
dumpLastProcessedLines() |
protected void |
enqueueToRedoQueue(int messageNr,
java.lang.String message) |
void |
fakeDisconnectClient() |
protected void |
flushQueuedContent()
Selector reported that client became writable again (after a prior
write attempt had not written all bytes).
|
java.nio.channels.SelectionKey |
getSelectorKey() |
java.nio.channels.SocketChannel |
getSocketChannel() |
private void |
handleEncoding(java.lang.String msg) |
long |
howLongAlreadyInTrouble() |
void |
initRedoQueueFromStub(ClientHandlerStub stub) |
boolean |
isGone() |
boolean |
isSpectator() |
protected boolean |
isStub() |
boolean |
isTemporarilyDisconnected() |
boolean |
isTemporarilyInTrouble() |
void |
processInput(java.nio.ByteBuffer byteBuffer) |
private void |
reEnqueue(MessageForClient mfc) |
private BattleHex |
resolveBattleHex(java.lang.String hexLabel) |
private CreatureType |
resolveCreatureType(java.lang.String name) |
private CreatureType |
resolveCreatureTypeNullOk(java.lang.String name)
There are cases where "null" comes over network and is not meant to
be resolved to a CreatureType, namely:
teleportingLord if no teleport; null recruiter; decline Acquire.
|
private Legion |
resolveLegion(java.lang.String markerId) |
private MasterHex |
resolveMasterHex(java.lang.String hexLabel) |
protected void |
sendToClient(java.lang.String message) |
private void |
sendViaChannel(java.lang.String msg) |
private void |
sendViaChannelRaw(java.lang.String msg) |
void |
setTemporarilyDisconnected() |
private void |
setTemporarilyInTrouble() |
boolean |
supportsReconnect() |
void |
syncAfterReconnect(int lastReceivedMessageNr,
int syncRequestNumber)
Re-send all data after the message from which we know client got it
|
boolean |
wasFakeDisconnectFlagSet() |
private void |
withdrawIfNeeded(boolean explicit)
Make sure player is withdrawn from game.
|
addCreature, appendToConnectionLog, askAcquireAngel, askChooseStrikePenalty, askConcede, askFlee, askNegotiate, askPickColor, askPickFirstMarker, cleanupBattle, confirmWhenCaughtUp, createSummonAngel, didMove, didRecruit, didSplit, didSummon, doReinforce, getClientName, getPlayerName, getSignonName, initBattle, initBoard, kickPhase, log, messageFromServer, nak, nextEngagement, pingRequest, placeNewChit, removeCreature, removeDeadBattleChits, removeLegion, revealCreatures, revealEngagedCreatures, serverConfirmsConnection, setBoardActive, setColor, setIsGone, setLegionStatus, setPlayerName, setupBattleFight, setupBattleMove, setupBattleRecruit, setupBattleSummon, setupFight, setupMove, setupMuster, setupSplit, setupTurnState, syncOption, tellBattleMove, tellEngagement, tellEngagementResults, tellGameOver, tellInitialGameInfo, tellLegionLocation, tellMovementRoll, tellPlayerElim, tellProposal, tellRedo, tellReplay, tellSlowResults, tellStrikeResults, tellSyncCompleted, tellWhatsHappening, undidMove, undidRecruit, undidSplit, updateCreatureCount, updateOnePlayersInfo, updatePlayerInfo
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addCreature, appendToConnectionLog, askAcquireAngel, askChooseStrikePenalty, askConcede, askFlee, askNegotiate, askPickColor, askPickFirstMarker, cleanupBattle, confirmWhenCaughtUp, createSummonAngel, didMove, didRecruit, didSplit, didSummon, doReinforce, initBattle, initBoard, kickPhase, log, messageFromServer, nak, nextEngagement, pingRequest, placeNewChit, removeCreature, removeDeadBattleChits, removeLegion, revealCreatures, revealEngagedCreatures, serverConfirmsConnection, setBoardActive, setColor, setLegionStatus, setPlayerName, setupBattleFight, setupBattleMove, setupBattleRecruit, setupBattleSummon, setupFight, setupMove, setupMuster, setupSplit, setupTurnState, syncOption, tellBattleMove, tellEngagement, tellEngagementResults, tellGameOver, tellLegionLocation, tellMovementRoll, tellPlayerElim, tellProposal, tellRedo, tellReplay, tellSlowResults, tellStrikeResults, tellSyncCompleted, tellWhatsHappening, undidMove, undidRecruit, undidSplit, updateCreatureCount, updateOnePlayersInfo, updatePlayerInfo
private static final java.util.logging.Logger LOGGER
private final java.nio.channels.SocketChannel socketChannel
private final java.nio.channels.SelectionKey selectorKey
private int clientVersion
private boolean spectator
private boolean didExplicitDisconnect
private boolean withdrawnAlready
private int cantSendMessageRepeated
private boolean temporarilyDisconnected
private boolean obsolete
private java.lang.String incompleteInput
private java.lang.String incompleteText
private static final java.lang.String DEFAULT_CHAR_SET
private final java.lang.String CHARSET_NAME
private final java.nio.charset.Charset charset
private final java.nio.charset.CharsetEncoder encoder
private final java.nio.charset.CharsetDecoder decoder
private int commitPointCounter
private static final int MAX_KEEP_LINES
private final java.util.ArrayList<java.lang.String> recentlyProcessedLines
private int newCounter
java.nio.ByteBuffer bb
java.lang.String encodedMsg
int should
int writtenTotal
int previousRetries
private long temporarilyInTrouble
java.util.LinkedList<java.lang.String> queue
public boolean fakeDisconnect
ClientHandler(Server server, java.nio.channels.SocketChannel channel, java.nio.channels.SelectionKey selKey)
public java.nio.channels.SelectionKey getSelectorKey()
public java.nio.channels.SocketChannel getSocketChannel()
public boolean isGone()
protected boolean isStub()
isStub
in class ClientHandlerStub
public boolean isSpectator()
public boolean didExplicitDisconnect()
public void setTemporarilyDisconnected()
public boolean isTemporarilyDisconnected()
protected boolean canHandlePingRequest()
canHandlePingRequest
in class ClientHandlerStub
protected boolean canHandleNewVariantXML()
public void disposeClient()
disposeClient
in interface IClient
disposeClient
in class ClientHandlerStub
public void processInput(java.nio.ByteBuffer byteBuffer)
private void sendViaChannel(java.lang.String msg)
protected void flushQueuedContent()
ClientHandlerStub
flushQueuedContent
in class ClientHandlerStub
protected void enqueueToRedoQueue(int messageNr, java.lang.String message)
enqueueToRedoQueue
in class ClientHandlerStub
protected void commitPoint()
commitPoint
in class ClientHandlerStub
private void confirmCommitPoint(int confirmedNr)
confirmedNr
- Commit point from which we now know that client has
successfully received itpublic boolean supportsReconnect()
supportsReconnect
in class ClientHandlerStub
public boolean canHandleBattleMoveNak()
public boolean canHandleAdvancedSync()
canHandleAdvancedSync
in class ClientHandlerStub
public void cloneRedoQueue(ClientHandler oldCH)
public void initRedoQueueFromStub(ClientHandlerStub stub)
private void reEnqueue(MessageForClient mfc)
public void syncAfterReconnect(int lastReceivedMessageNr, int syncRequestNumber)
lastReceivedMessageNr
- Last message which client did still receivesyncRequestNumber
- Every request has own unique id, so we don't mix thempublic boolean isTemporarilyInTrouble()
public long howLongAlreadyInTrouble()
private void setTemporarilyInTrouble()
public void clearTemporarilyInTrouble()
private void handleEncoding(java.lang.String msg)
private void sendViaChannelRaw(java.lang.String msg)
private void attemptWritingToChannel()
private void withdrawIfNeeded(boolean explicit)
explicit
- Whether client has requested withdraw explicitlypublic void declareObsolete()
public java.lang.String dumpLastProcessedLines()
private void doCallMethodInTryBlock(java.lang.String line, java.lang.String method, java.util.List<java.lang.String> li)
private void callMethod(java.lang.String method, java.util.List<java.lang.String> args)
method
- The method to executeargs
- A list of argument Stringsprivate BattleHex resolveBattleHex(java.lang.String hexLabel)
private CreatureType resolveCreatureType(java.lang.String name)
private CreatureType resolveCreatureTypeNullOk(java.lang.String name)
name
- Name of the creatureType to find, might be "null"private MasterHex resolveMasterHex(java.lang.String hexLabel)
private Legion resolveLegion(java.lang.String markerId)
protected void sendToClient(java.lang.String message)
sendToClient
in class ClientHandlerStub
public void fakeDisconnectClient()
public void clearDisconnectClient()
public boolean wasFakeDisconnectFlagSet()