コード例 #1
0
    public override void ConnectRequest(UdpEndPoint endpoint, IProtocolToken token)
    {
        //check UserID and SessionID


        TestToken myToken = (TestToken)token;



        //ask GameLift to verify sessionID is valid, it will change player slot from "RESERVED" to "ACTIVE"
        Aws.GameLift.GenericOutcome outCome = GameLiftServerAPI.AcceptPlayerSession(myToken.ArbitraryData);
        if (outCome.Success)
        {
            BoltNetwork.Accept(endpoint);
        }
        else
        {
            BoltNetwork.Refuse(endpoint);
        }

        /*
         * This data type is used to specify which player session(s) to retrieve.
         * It can be used in several ways:
         * (1) provide a PlayerSessionId to request a specific player session;
         * (2) provide a GameSessionId to request all player sessions in the specified game session; or
         * (3) provide a PlayerId to request all player sessions for the specified player.
         * For large collections of player sessions,
         * use the pagination parameters to retrieve results as sequential pages.
         *
         */
        var aaa = new DescribePlayerSessionsRequest()
        {
            PlayerSessionId = myToken.ArbitraryData,
            // GameSessionId = myToken.ArbitraryData,
            // PlayerId =
        };



        Aws.GameLift.DescribePlayerSessionsOutcome DPSO = GameLiftServerAPI.DescribePlayerSessions(aaa);
        string TheirPlayerId = DPSO.Result.PlayerSessions[0].PlayerId;

        Debug.Log(TheirPlayerId);
    }
コード例 #2
0
        private static bool OnHealthCheck()
        {
            healthChecks++;
            log.Info("Heartbeat - " + healthChecks);
            DescribePlayerSessionsOutcome result = GameLiftServerAPI.DescribePlayerSessions(new DescribePlayerSessionsRequest
            {
                GameSessionId = appgame.gameSessionId
            });
            bool timedOut = result.Result.PlayerSessions.Count > 0;

            foreach (PlayerSession ps in result.Result.PlayerSessions)
            {
                timedOut = timedOut && (ps.Status == PlayerSessionStatus.TIMEDOUT);
            }
            if (timedOut)
            {
                EndGame();
            }
            if (healthChecks == 10 && result.Result.PlayerSessions.Count == 0)
            {
                EndGame();
            }
            return(true);
        }