コード例 #1
0
    public void UpdateFleetIQ(bool serverTerminated = false)
    {
        // Only update if we're ready
        if (this.server.IsReady())
        {
            Console.WriteLine("Server Ready, updating to FleetIQ");

            var utilizationStatus = GameServerUtilizationStatus.AVAILABLE;

            // If we have a player connected, we're utilized (backend has claimed this game server for 2 players)
            if (this.server.GetPlayerCount() > 0)
            {
                utilizationStatus = GameServerUtilizationStatus.UTILIZED;
            }

            var gameLiftConfig = new AmazonGameLiftConfig {
                RegionEndpoint = this.regionEndpoint
            };
            var gameLiftClient          = new AmazonGameLiftClient(gameLiftConfig);
            var updateGameServerRequest = new UpdateGameServerRequest();
            updateGameServerRequest.GameServerGroupName = Server.fleetIqGameServerGroup;
            updateGameServerRequest.GameServerId        = this.gameServerId;
            updateGameServerRequest.HealthCheck         = GameServerHealthCheck.HEALTHY;
            updateGameServerRequest.UtilizationStatus   = utilizationStatus;

            gameLiftClient.UpdateGameServerAsync(updateGameServerRequest);

            Console.WriteLine("FleetIQ Updat sent!");
        }
    }