示例#1
0
            private void Disconnect()
            {
                MainServerComms.Disconnect();

                Socket        = null;
                Stream        = null;
                ReceiveBuffer = null;
                ReceivePacket = null;
            }
        public static void Welcome(Packet _)
        {
            Output.WriteLine("\t\tGameServer reading welcome packet from MainServer");
            MainServerComms.EstablishedConnection = true;

            //Thread updateThread = new Thread(new ThreadStart(MainServerComms.Update));
            //updateThread.Start();
            MainServerComms.StartSendingServerData();

            MainServerCommsSend.WelcomeReceived(MainServerComms.ServerName);
            Output.WriteLine("\t\tGameServer recieved welcome packet from MainServer");
        }
示例#3
0
        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}");
            }
        }
示例#4
0
        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}");
            }
        }