Class RunGameInOwnJVM

  • All Implemented Interfaces:
    java.lang.Runnable, IGameRunner

    public class RunGameInOwnJVM
    extends java.lang.Thread
    implements IGameRunner
    This class runs (starts and supervises) a Game on the Game Server (as opposed to: on the User's PC). It finds and reserves a port for it, starts it in a separate process and when the process terminates, join()s it and releases the port. If the game is run on a user's PC, the class RunGameInSameJVM will be used.
    Author:
    Clemens Katzer
    • Field Detail

      • LOGGER

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

        private int hostingPort
      • hostingHost

        private java.lang.String hostingHost
      • gameId

        private final java.lang.String gameId
      • workFilesBaseDir

        private java.lang.String workFilesBaseDir
      • template

        private java.lang.String template
      • javaCommand

        private java.lang.String javaCommand
      • colossusJar

        private java.lang.String colossusJar
      • flagFile

        private java.io.File flagFile
      • alreadyStarted

        private boolean alreadyStarted
      • reasonStartFailed

        private java.lang.String reasonStartFailed
    • Method Detail

      • getReasonStartFailed

        public java.lang.String getReasonStartFailed()
      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
        Overrides:
        run in class java.lang.Thread
      • runInOwnJVM

        private void runInOwnJVM()
      • createServerCfgFile

        private boolean createServerCfgFile​(java.io.File gameDir)
      • createLoggingPropertiesFromTemplate

        private boolean createLoggingPropertiesFromTemplate​(java.io.File logPropTemplate,
                                                            java.io.File logPropFile)
      • superviseGameStartup

        private void superviseGameStartup()
      • isSocketUp

        private boolean isSocketUp()
      • 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
      • waitForLine

        private java.lang.String waitForLine​(java.io.BufferedReader in,
                                             int checkInterval)
      • getMissingPlayers

        private java.lang.String getMissingPlayers​(java.util.List<java.lang.String> names)
      • listAsString

        public java.lang.String listAsString​(java.util.List<java.lang.String> names)
      • sleepFor

        private void sleepFor​(long millis)