Package net.sf.colossus.webclient
Class RunGameInSameJVM
- java.lang.Object
-
- java.lang.Thread
-
- net.sf.colossus.webclient.RunGameInSameJVM
-
- All Implemented Interfaces:
java.lang.Runnable,INotifyWebServer,IGameRunner
public class RunGameInSameJVM extends java.lang.Thread implements IGameRunner, INotifyWebServer
-
-
Field Summary
Fields Modifier and Type Field Description private static WebClientinitiatingWebClientprivate static java.util.logging.LoggerLOGGERprivate OptionspresetOptionsTo exchange data between us and the GetPlayersWeb dialog when game is started locallyprivate IStartHandlerstartHandlerprivate java.lang.Stringusernameprivate WebClientwebClientprivate WhatNextManagerwhatNextManager-
Fields inherited from interface net.sf.colossus.server.INotifyWebServer
ALL_CLIENTS_CONNECTED, GAME_STARTUP_COMPLETED, GAME_STARTUP_FAILED
-
-
Constructor Summary
Constructors Constructor Description RunGameInSameJVM(GameInfo gi, WhatNextManager whatNextMgr, java.lang.String username, WebClient webClient)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidallClientsConnected()voidgameStartupCompleted()voidgameStartupFailed(java.lang.String reason)java.lang.StringgetHostingHost()java.lang.StringgetHostingPlayerName()intgetHostingPort()static WebClientgetInitiatingWebClient()if a Game Server game was started locally on players computer, then GameServerSide queries the starting web client from here.private WebClientgetWebClient()voidgotClient(java.lang.String playerName, boolean remote)booleanisActive()booleanmakeRunningGame()voidreadyToAcceptClients()voidrun()voidrunGameInSameJVM()(package private) voidrunGetPlayersDialogAndWait(Options presetOptions, WhatNextManager whatNextManager)voidserverStoppedRunning()voidsetServerNull()static voidsleepFor(long millis)voidtellServerToInformOtherPlayers()booleantryToStart()booleanwaitUntilGameStartedSuccessfully(int timeout)booleanwaitUntilReadyToAcceptClients(int timeout)Waits until socket is up, i.e.-
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
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.colossus.webcommon.IGameRunner
start
-
-
-
-
Field Detail
-
LOGGER
private static final java.util.logging.Logger LOGGER
-
presetOptions
private final Options presetOptions
To exchange data between us and the GetPlayersWeb dialog when game is started locally
-
webClient
private final WebClient webClient
-
whatNextManager
private final WhatNextManager whatNextManager
-
initiatingWebClient
private static WebClient initiatingWebClient
-
username
private final java.lang.String username
-
startHandler
private final IStartHandler startHandler
-
-
Constructor Detail
-
RunGameInSameJVM
public RunGameInSameJVM(GameInfo gi, WhatNextManager whatNextMgr, java.lang.String username, WebClient webClient)
-
-
Method Detail
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable- Overrides:
runin classjava.lang.Thread
-
runGameInSameJVM
public void runGameInSameJVM()
-
runGetPlayersDialogAndWait
void runGetPlayersDialogAndWait(Options presetOptions, WhatNextManager whatNextManager)
-
tellServerToInformOtherPlayers
public void tellServerToInformOtherPlayers()
-
sleepFor
public static void sleepFor(long millis)
-
getWebClient
private WebClient getWebClient()
-
getInitiatingWebClient
public static WebClient getInitiatingWebClient()
if a Game Server game was started locally on players computer, then GameServerSide queries the starting web client from here.- Returns:
- The last WebClient that initiated a game start.
-
getHostingPlayerName
public java.lang.String getHostingPlayerName()
-
getHostingHost
public java.lang.String getHostingHost()
- Specified by:
getHostingHostin interfaceIGameRunner
-
getHostingPort
public int getHostingPort()
- Specified by:
getHostingPortin interfaceIGameRunner
-
makeRunningGame
public boolean makeRunningGame()
- Specified by:
makeRunningGamein interfaceIGameRunner
-
tryToStart
public boolean tryToStart()
- Specified by:
tryToStartin interfaceIGameRunner
-
setServerNull
public void setServerNull()
-
waitUntilGameStartedSuccessfully
public boolean waitUntilGameStartedSuccessfully(int timeout)
- Specified by:
waitUntilGameStartedSuccessfullyin interfaceIGameRunner
-
waitUntilReadyToAcceptClients
public boolean waitUntilReadyToAcceptClients(int timeout)
Description copied from interface:IGameRunnerWaits until socket is up, i.e. game is ready to accept clients.- Specified by:
waitUntilReadyToAcceptClientsin interfaceIGameRunner
-
isActive
public boolean isActive()
- Specified by:
isActivein interfaceINotifyWebServer
-
readyToAcceptClients
public void readyToAcceptClients()
- Specified by:
readyToAcceptClientsin interfaceINotifyWebServer
-
gotClient
public void gotClient(java.lang.String playerName, boolean remote)- Specified by:
gotClientin interfaceINotifyWebServer
-
allClientsConnected
public void allClientsConnected()
- Specified by:
allClientsConnectedin interfaceINotifyWebServer
-
gameStartupCompleted
public void gameStartupCompleted()
- Specified by:
gameStartupCompletedin interfaceINotifyWebServer
-
gameStartupFailed
public void gameStartupFailed(java.lang.String reason)
- Specified by:
gameStartupFailedin interfaceINotifyWebServer
-
serverStoppedRunning
public void serverStoppedRunning()
- Specified by:
serverStoppedRunningin interfaceINotifyWebServer
-
-