net.sf.colossus.webclient
Class RunGameInSameJVM

java.lang.Object
  extended by java.lang.Thread
      extended by net.sf.colossus.webclient.RunGameInSameJVM
All Implemented Interfaces:
java.lang.Runnable, INotifyWebServer, IGameRunner

public class RunGameInSameJVM
extends java.lang.Thread
implements IGameRunner, INotifyWebServer


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
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 locally
private  IStartHandler startHandler
           
private  java.lang.String username
           
private  WebClient webClient
           
private  WhatNextManager whatNextManager
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Fields inherited from interface net.sf.colossus.server.INotifyWebServer
ALL_CLIENTS_CONNECTED, GAME_STARTUP_COMPLETED, GAME_STARTUP_FAILED
 
Constructor Summary
RunGameInSameJVM(GameInfo gi, WhatNextManager whatNextMgr, java.lang.String username, WebClient webClient)
           
 
Method Summary
 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, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, 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 interface java.lang.Runnable
Overrides:
run in class java.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 interface IGameRunner

getHostingPort

public int getHostingPort()
Specified by:
getHostingPort in interface IGameRunner

makeRunningGame

public boolean makeRunningGame()
Specified by:
makeRunningGame in interface IGameRunner

tryToStart

public boolean tryToStart()
Specified by:
tryToStart in interface IGameRunner

setServerNull

public void setServerNull()

waitUntilGameStartedSuccessfully

public boolean waitUntilGameStartedSuccessfully(int timeout)
Specified by:
waitUntilGameStartedSuccessfully in interface IGameRunner

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 interface IGameRunner

isActive

public boolean isActive()
Specified by:
isActive in interface INotifyWebServer

readyToAcceptClients

public void readyToAcceptClients()
Specified by:
readyToAcceptClients in interface INotifyWebServer

gotClient

public void gotClient(java.lang.String playerName,
                      boolean remote)
Specified by:
gotClient in interface INotifyWebServer

allClientsConnected

public void allClientsConnected()
Specified by:
allClientsConnected in interface INotifyWebServer

gameStartupCompleted

public void gameStartupCompleted()
Specified by:
gameStartupCompleted in interface INotifyWebServer

gameStartupFailed

public void gameStartupFailed(java.lang.String reason)
Specified by:
gameStartupFailed in interface INotifyWebServer

serverStoppedRunning

public void serverStoppedRunning()
Specified by:
serverStoppedRunning in interface INotifyWebServer