public static void StartServerProgram(string[] args) { string serverName = args[0]; Output.WriteLine(serverName); int maxNumPlayers = int.Parse(args[1]); Output.WriteLine(maxNumPlayers.ToString()); string mapName = args[2]; Output.WriteLine(mapName); int portGame = int.Parse(args[3]); Output.WriteLine(portGame.ToString()); int portMainServer = int.Parse(args[4]); Output.WriteLine(portMainServer.ToString()); int timeOutSeconds = int.Parse(args[5]); Output.WriteLine(timeOutSeconds.ToString()); bool isServerPermanent = bool.Parse(args[6]); Output.WriteLine(isServerPermanent.ToString()); string mainServerIP = args[7]; Output.WriteLine(mainServerIP); try { Output.InitLogFile($"GameServer_{serverName}"); SceneManager.LoadScene(mapName); MainServerComms.Connect(portMainServer, serverName, mainServerIP); Server.StartServer(serverName, maxNumPlayers, mapName, portGame, timeOutSeconds, isServerPermanent); } catch (Exception exception) { Output.WriteLine($"\tError starting server:\n{exception}"); } }
public static void StartServerProgram(string[] args) { (string serverName, int maxNumPlayers, string mapName, int portGame, int portMainServer, int timeOut) = (args[0], int.Parse(args[1]), args[2], int.Parse(args[3]), int.Parse(args[4]), int.Parse(args[5])); Thread mainThread = new Thread(new ThreadStart(MainThread)); mainThread.Start(); PortGame = portGame; try { MainServerComms.Connect(portMainServer, serverName, timeOut); Server.StartServer(serverName, maxNumPlayers, mapName, portGame); } catch (Exception exception) { Console.WriteLine($"\tError starting server:\n{exception}"); } }