Class ClientHandlerStub

  • All Implemented Interfaces:
    IClient
    Direct Known Subclasses:
    ClientHandler

    public class ClientHandlerStub
    extends java.lang.Object
    implements IClient
    • Field Detail

      • LOGGER

        private static final java.util.logging.Logger LOGGER
      • server

        protected Server server
      • counter

        protected static int counter
      • isGone

        protected boolean isGone
      • playerName

        protected java.lang.String playerName
      • signonName

        protected java.lang.String signonName
      • messageCounter

        protected int messageCounter
      • isCommitPoint

        protected boolean isCommitPoint
      • previousInfoStringsString

        private java.lang.String previousInfoStringsString
      • alreadyHandled

        private int alreadyHandled
    • Constructor Detail

      • ClientHandlerStub

        public ClientHandlerStub​(Server server)
    • Method Detail

      • isStub

        protected boolean isStub()
      • canHandlePingRequest

        protected boolean canHandlePingRequest()
      • canHandleAdvancedSync

        public boolean canHandleAdvancedSync()
      • supportsReconnect

        protected boolean supportsReconnect()
      • setIsGone

        public void setIsGone​(java.lang.String reason)
      • sendToClient

        protected void sendToClient​(java.lang.String message)
      • flushQueuedContent

        protected void flushQueuedContent()
        Selector reported that client became writable again (after a prior write attempt had not written all bytes). Now start/try writing the message(s) which are still in the queue.
      • enqueueToRedoQueue

        protected void enqueueToRedoQueue​(int messageNr,
                                          java.lang.String message)
      • commitPoint

        protected void commitPoint()
      • disposeClient

        public void disposeClient()
        Server side disposes a client (and informs it about it first) To be used only for "disposeAllClients()", otherwise setIsGone reason is misleading.
        Specified by:
        disposeClient in interface IClient
      • tellEngagementResults

        public void tellEngagementResults​(Legion winner,
                                          java.lang.String method,
                                          int points,
                                          int turns)
        Specified by:
        tellEngagementResults in interface IClient
      • tellWhatsHappening

        public void tellWhatsHappening​(java.lang.String message)
        Specified by:
        tellWhatsHappening in interface IClient
      • tellMovementRoll

        public void tellMovementRoll​(int roll)
        Specified by:
        tellMovementRoll in interface IClient
      • syncOption

        public void syncOption​(java.lang.String optname,
                               java.lang.String value)
        Specified by:
        syncOption in interface IClient
      • updatePlayerInfo

        public void updatePlayerInfo​(java.util.List<java.lang.String> infoStrings)
        Specified by:
        updatePlayerInfo in interface IClient
      • updateOnePlayersInfo

        public void updateOnePlayersInfo​(boolean redundant,
                                         java.lang.String reason,
                                         java.lang.String ShouldBeSeveralSeparateVariablesHerePerhaps)
        A new way to pass changed player info to clients. Shortened info (e.g. color, dead state, ...) not sent every time; Includes a reason why sent (mostly used internally on server side for debugging/development purposes), and a flag whether this info should be redundant; idea behind it: on the long run, clients should be able to update game/player info "autonomously" (same logic implemented on client as on server) instead of server doing it and synching to all clients. So this redundant is meant to be used as safety net to detect where that new approach might miss something.
        Specified by:
        updateOnePlayersInfo in interface IClient
      • revealEngagedCreatures

        public void revealEngagedCreatures​(Legion legion,
                                           java.util.List<CreatureType> creatures,
                                           boolean isAttacker,
                                           java.lang.String reason)
        print the 'revealEngagagedCreature'-message, args: markerId, isAttacker, list of creature names
        Specified by:
        revealEngagedCreatures in interface IClient
        Parameters:
        markerId - legion marker name that is currently in battle
        creatures - List of creatures in this legion
        isAttacker - true for attacker, false for defender
        reason - why this was revealed
      • placeNewChit

        public void placeNewChit​(java.lang.String imageName,
                                 boolean inverted,
                                 int tag,
                                 BattleHex hex)
        Specified by:
        placeNewChit in interface IClient
      • tellReplay

        public void tellReplay​(boolean val,
                               int maxTurn)
        Specified by:
        tellReplay in interface IClient
      • tellRedo

        public void tellRedo​(boolean val)
        Specified by:
        tellRedo in interface IClient
      • initBoard

        public void initBoard()
        Specified by:
        initBoard in interface IClient
      • setPlayerName

        public void setPlayerName​(java.lang.String playerName)
        Specified by:
        setPlayerName in interface IClient
      • getSignonName

        public java.lang.String getSignonName()
      • getClientName

        public java.lang.String getClientName()
      • getPlayerName

        public java.lang.String getPlayerName()
      • askChooseStrikePenalty

        public void askChooseStrikePenalty​(java.util.List<java.lang.String> choices)
        Specified by:
        askChooseStrikePenalty in interface IClient
      • tellGameOver

        public void tellGameOver​(java.lang.String message,
                                 boolean disposeFollows)
        Specified by:
        tellGameOver in interface IClient
      • tellProposal

        public void tellProposal​(java.lang.String proposalString)
        Specified by:
        tellProposal in interface IClient
      • tellSlowResults

        public void tellSlowResults​(int targetTag,
                                    int slowValue)
        Specified by:
        tellSlowResults in interface IClient
      • tellStrikeResults

        public void tellStrikeResults​(int strikerTag,
                                      int targetTag,
                                      int strikeNumber,
                                      java.util.List<java.lang.String> rolls,
                                      int damage,
                                      boolean killed,
                                      boolean wasCarry,
                                      int carryDamageLeft,
                                      java.util.Set<java.lang.String> carryTargetDescriptions)
        Specified by:
        tellStrikeResults in interface IClient
      • setupTurnState

        public void setupTurnState​(Player activePlayer,
                                   int turnNumber)
        Specified by:
        setupTurnState in interface IClient
      • setupSplit

        public void setupSplit​(Player activePlayer,
                               int turnNumber)
        Specified by:
        setupSplit in interface IClient
      • setupMove

        public void setupMove()
        Specified by:
        setupMove in interface IClient
      • setupFight

        public void setupFight()
        Specified by:
        setupFight in interface IClient
      • setupMuster

        public void setupMuster()
        Specified by:
        setupMuster in interface IClient
      • kickPhase

        public void kickPhase()
        Specified by:
        kickPhase in interface IClient
      • setupBattleSummon

        public void setupBattleSummon​(Player battleActivePlayer,
                                      int battleTurnNumber)
        Specified by:
        setupBattleSummon in interface IClient
      • setupBattleRecruit

        public void setupBattleRecruit​(Player battleActivePlayer,
                                       int battleTurnNumber)
        Specified by:
        setupBattleRecruit in interface IClient
      • setupBattleMove

        public void setupBattleMove​(Player battleActivePlayer,
                                    int battleTurnNumber)
        Specified by:
        setupBattleMove in interface IClient
      • log

        public void log​(java.lang.String message)
        Specified by:
        log in interface IClient
      • nak

        public void nak​(java.lang.String reason,
                        java.lang.String errmsg)
        Specified by:
        nak in interface IClient
      • setBoardActive

        public void setBoardActive​(boolean val)
        Specified by:
        setBoardActive in interface IClient
      • tellInitialGameInfo

        public void tellInitialGameInfo​(java.lang.String variantName,
                                        java.util.Collection<java.lang.String> playerNames)
      • pingRequest

        public void pingRequest()
        Specified by:
        pingRequest in interface IClient
      • messageFromServer

        public void messageFromServer​(java.lang.String message)
        Specified by:
        messageFromServer in interface IClient
      • appendToConnectionLog

        public void appendToConnectionLog​(java.lang.String message)
        Specified by:
        appendToConnectionLog in interface IClient
      • tellSyncCompleted

        public void tellSyncCompleted​(int syncRequestNumber)
        Specified by:
        tellSyncCompleted in interface IClient