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 WebClient
initiatingWebClient
private static java.util.logging.Logger
LOGGER
private Options
presetOptions
To exchange data between us and the GetPlayersWeb dialog when game is started locallyprivate IStartHandler
startHandler
private java.lang.String
username
private WebClient
webClient
private WhatNextManager
whatNextManager
-
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 void
allClientsConnected()
void
gameStartupCompleted()
void
gameStartupFailed(java.lang.String reason)
java.lang.String
getHostingHost()
java.lang.String
getHostingPlayerName()
int
getHostingPort()
static WebClient
getInitiatingWebClient()
if a Game Server game was started locally on players computer, then GameServerSide queries the starting web client from here.private WebClient
getWebClient()
void
gotClient(java.lang.String playerName, boolean remote)
boolean
isActive()
boolean
makeRunningGame()
void
readyToAcceptClients()
void
run()
void
runGameInSameJVM()
(package private) void
runGetPlayersDialogAndWait(Options presetOptions, WhatNextManager whatNextManager)
void
serverStoppedRunning()
void
setServerNull()
static void
sleepFor(long millis)
void
tellServerToInformOtherPlayers()
boolean
tryToStart()
boolean
waitUntilGameStartedSuccessfully(int timeout)
boolean
waitUntilReadyToAcceptClients(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:
run
in interfacejava.lang.Runnable
- Overrides:
run
in 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:
getHostingHost
in interfaceIGameRunner
-
getHostingPort
public int getHostingPort()
- Specified by:
getHostingPort
in interfaceIGameRunner
-
makeRunningGame
public boolean makeRunningGame()
- Specified by:
makeRunningGame
in interfaceIGameRunner
-
tryToStart
public boolean tryToStart()
- Specified by:
tryToStart
in interfaceIGameRunner
-
setServerNull
public void setServerNull()
-
waitUntilGameStartedSuccessfully
public boolean waitUntilGameStartedSuccessfully(int timeout)
- Specified by:
waitUntilGameStartedSuccessfully
in interfaceIGameRunner
-
waitUntilReadyToAcceptClients
public boolean waitUntilReadyToAcceptClients(int timeout)
Description copied from interface:IGameRunner
Waits until socket is up, i.e. game is ready to accept clients.- Specified by:
waitUntilReadyToAcceptClients
in interfaceIGameRunner
-
isActive
public boolean isActive()
- Specified by:
isActive
in interfaceINotifyWebServer
-
readyToAcceptClients
public void readyToAcceptClients()
- Specified by:
readyToAcceptClients
in interfaceINotifyWebServer
-
gotClient
public void gotClient(java.lang.String playerName, boolean remote)
- Specified by:
gotClient
in interfaceINotifyWebServer
-
allClientsConnected
public void allClientsConnected()
- Specified by:
allClientsConnected
in interfaceINotifyWebServer
-
gameStartupCompleted
public void gameStartupCompleted()
- Specified by:
gameStartupCompleted
in interfaceINotifyWebServer
-
gameStartupFailed
public void gameStartupFailed(java.lang.String reason)
- Specified by:
gameStartupFailed
in interfaceINotifyWebServer
-
serverStoppedRunning
public void serverStoppedRunning()
- Specified by:
serverStoppedRunning
in interfaceINotifyWebServer
-
-