private void OnApplicationQuit()
 {
     if (isHeadlessServer)
     {
         TerminateSession();
         GameLiftServerAPI.Destroy();
     }
 }
コード例 #2
0
        void OnProcessTerminate()
        {
            // game-specific tasks required to gracefully shut down a game session,
            // such as notifying players, preserving game state data, and other cleanup
            var ProcessEndingOutcome = GameLiftServerAPI.ProcessEnding();

            GameLiftServerAPI.Destroy();
            this.running = false;
        }
コード例 #3
0
    void OnApplicationQuit()
    {
        if (started == true)
        {
            GameLiftServerAPI.Destroy();
        }

        //Make sure to call GameLiftServerAPI.Destroy() when the application quits.
        //This resets the local connection with GameLift's agent.
        //bool headless = IsHeadlessMode();
        //if (headless == true || StartEvenIfNotHeadless)
        //{
        //     GameLiftServerAPI.Destroy();
        // }
    }
コード例 #4
0
        private void OnApplicationQuit()
        {
            //Notifies the GameLift service that the server process is shutting down. This method should be called
            //AFTER all other cleanup tasks, including shutting down all active game sessions.
            //This method should exit with an exit code of 0;
            //a non-zero exit code results in an event message that the process did not exit cleanly.
            var outcome = GameLiftServerAPI.ProcessEnding();

            Debug.Log(outcome.Success
        ? ":) PROCESSENDING"
        : $":( PROCESSENDING FAILED. ProcessEnding() returned {outcome.Error}");

            //Make sure to call GameLiftServerAPI.Destroy() when the application quits.
            //This resets the local connection with GameLift's agent.
            GameLiftServerAPI.Destroy();
        }
コード例 #5
0
        public API()
        {
            Get["/end"] = _ =>
            {
                GameLiftServerAPI.TerminateGameSession();
                Console.WriteLine("DESTROYING SESSION");

                return(200);
            };

            Get["/shutdown"] = _ =>
            {
                GameLiftServerAPI.Destroy();
                return(200);
            };

            Post["/start"] = _ =>
            {
                try
                {
                    var    body   = this.Request.Body;
                    int    length = (int)body.Length;                  // this is a dynamic variable
                    byte[] data   = new byte[length];
                    body.Read(data, 0, length);
                    PlayerType json = this.Bind <PlayerType>();

                    Console.WriteLine(json.session_id);

                    var acceptPlayerSessionOutcome = GameLiftServerAPI.AcceptPlayerSession(json.session_id);

                    return(200);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                return(200);
            };
        }
コード例 #6
0
 void OnApplicationQuit()
 {
     //Make sure to call GameLiftServerAPI.Destroy() when the application quits. This resets the local connection with GameLift's agent.
     GameLiftServerAPI.Destroy();
 }
コード例 #7
0
 void OnApplicationQuit()
 {
     EndServerProcess();
     GameLiftServerAPI.Destroy();
 }
コード例 #8
0
        static int Main(string[] args)
        {
            var listeningPort = 7777;
            var waitHandle    = new AutoResetEvent(false);

            var initSDKOutcome = GameLiftServerAPI.InitSDK();

            if (initSDKOutcome.Success)
            {
                ProcessParameters processParameters = new ProcessParameters(
                    // OnGameSession callback
                    (gameSession) =>
                {
                    Console.WriteLine("OnGameSession received.");
                    var activateGameSessionOutcome = GameLiftServerAPI.ActivateGameSession();
                    if (activateGameSessionOutcome.Success)
                    {
                        Console.WriteLine("ActivateGameSession success.");
                    }
                    else
                    {
                        Console.WriteLine("ActivateGameSession failure : " + activateGameSessionOutcome.Error.ToString());
                    }
                },

                    // OnProcessTerminate callback
                    () =>
                {
                    Console.WriteLine("OnProcessTerminate received.");
                    waitHandle.Set();
                },

                    // OnHealthCheck
                    () =>
                {
                    Console.WriteLine("OnHealthCheck received.");
                    return(true);
                },

                    listeningPort,

                    new LogParameters(new List <string>()
                {
                    "/local/game/logs/myserver.log"
                })
                    );

                var processReadyOutcome = GameLiftServerAPI.ProcessReady(processParameters);
                if (processReadyOutcome.Success)
                {
                    Console.WriteLine("ProcessReady success.");
                }
                else
                {
                    Console.WriteLine("ProcessReady failure : " + processReadyOutcome.Error.ToString());
                }
            }
            else
            {
                Console.WriteLine("InitSDK failure : " + initSDKOutcome.Error.ToString());
            }

            Console.CancelKeyPress += new ConsoleCancelEventHandler(
                (object sender, ConsoleCancelEventArgs eventArgs) =>
            {
                Console.WriteLine("The read operation has been interrupted.");
                Console.WriteLine($"  Key pressed: {eventArgs.SpecialKey}");
                Console.WriteLine($"  Cancel property: {eventArgs.Cancel}");

                Console.WriteLine("Setting the Cancel property to true...");
                eventArgs.Cancel = true;

                Console.WriteLine($"  Cancel property: {eventArgs.Cancel}");
                Console.WriteLine("The read operation will resume...");
                waitHandle.Set();
            }
                );

            waitHandle.WaitOne();

            var processEndingOutcome = GameLiftServerAPI.ProcessEnding();

            if (processEndingOutcome.Success)
            {
                Console.WriteLine("ProcessEnding success.");
            }
            else
            {
                Console.WriteLine("ProcessEnding failure : " + processEndingOutcome.Error.ToString());
            }

            GameLiftServerAPI.Destroy();

            return(0);
        }
コード例 #9
0
 private static void OnProcessTerminate()
 {
     GameLiftServerAPI.ProcessEnding();
     GameLiftServerAPI.Destroy();
     System.Environment.Exit(0);
 }