Esempio n. 1
0
        private static void OnAcceptPlayerSession() // (NetworkMessage netMsg)
        {
            // Messages.AcceptPlayerSessionMessage msg = netMsg.ReadMessage<Messages.AcceptPlayerSessionMessage>();
            GenericOutcome outcome = GameLiftServerAPI.AcceptPlayerSession(""); // msg.playerSessionId);

            if (!outcome.Success)
            {
                log.Error(outcome);
                return;
            }
        }
Esempio n. 2
0
    public bool AcceptPlayer(string playerSessionId)
    {
        var acceptPlayerSessionOutcome = GameLiftServerAPI.AcceptPlayerSession(playerSessionId);

        if (acceptPlayerSessionOutcome.Success)
        {
            LogModule.WriteToLogFile("[GameLift] Player Session Validated");
            return(true);
        }
        else
        {
            LogModule.WriteToLogFile("[GameLift] Player Session Rejected. AcceptPlayerSession Result : " + acceptPlayerSessionOutcome.Error.ToString());
            return(false);
        }
    }
Esempio n. 3
0
    private void HandleConnect(int playerIdx, string json, TcpClient client)
    {
        // respond with the player id and the current state.
        //Connect player
        var outcome = GameLiftServerAPI.AcceptPlayerSession(json);

        if (outcome.Success)
        {
            System.Console.WriteLine(":) PLAYER SESSION VALIDATED");
        }
        else
        {
            System.Console.WriteLine(":( PLAYER SESSION REJECTED. AcceptPlayerSession() returned " + outcome.Error.ToString());
            this.clientsToRemove.Add(client);
        }
    }
Esempio n. 4
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);
    }
        // Called from MLAPI on new client connection
        public bool ConnectPlayer(ulong clientId, string playerSessionId)
        {
            try {
                //Notifies the GameLift service that a player with the specified player session ID has connected to the
                //server process and needs validation. GameLift verifies that the player session ID is valid—that is,
                //that the player ID has reserved a player slot in the game session. Once validated,
                //GameLift changes the status of the player slot from RESERVED to ACTIVE.
                var outcome = GameLiftServerAPI.AcceptPlayerSession(playerSessionId);
                Debug.Log(outcome.Success
          ? ":) PLAYER SESSION VALIDATED"
          : $":( PLAYER SESSION REJECTED. AcceptPlayerSession() returned {outcome.Error}");

                playerSessions.Add(clientId, playerSessionId);
                idleCancelTokenSource.Cancel();
                return(outcome.Success);
            }
            catch (Exception e) {
                Debug.Log($":( REJECTED PLAYER SESSION. AcceptPlayerSession() exception \n{e.Message}");
                return(false);
            }
        }
Esempio n. 6
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);
            };
        }
Esempio n. 7
0
        private void OnConnectionRequestEvent(ConnectionRequest request)
        {
            // PlayerSessionId を接続時に受け取って GameLift に問い合わせる
            var pid = request.Data.GetString();

            _logger.InfoFormat("playerSessionId: {0}", pid);
            var res = GameLiftServerAPI.AcceptPlayerSession(pid);

            if (!res.Success)
            {
                request.Reject();
                return;
            }

            if (!_playerEndPoints.Add(request.RemoteEndPoint, pid))
            {
                request.Reject();
                return;
            }

            request.Accept();
        }
Esempio n. 8
0
    public bool ConnectPlayer(int playerIdx, string playerSessionId)
    {
        try
        {
            var outcome = GameLiftServerAPI.AcceptPlayerSession(playerSessionId);
            if (outcome.Success)
            {
                Debug.Log(":) PLAYER SESSION VALIDATED");
            }
            else
            {
                Debug.Log(":( PLAYER SESSION REJECTED. AcceptPlayerSession() returned " + outcome.Error.ToString());
            }

            playerSessions.Add(playerIdx, playerSessionId);
            return(outcome.Success);
        }
        catch (Exception e)
        {
            Debug.Log(":( REJECTED PLAYER SESSION. AcceptPlayerSession() exception " + Environment.NewLine + e.Message);
            return(false);
        }
    }
        public bool AcceptPlayerSession(string playerSessionId)
        {
            var acceptOutcome = GameLiftServerAPI.AcceptPlayerSession(playerSessionId);

            return(acceptOutcome.Success);
        }
Esempio n. 10
0
 public GenericOutcome AcceptPlayerSession(string playerSessionId)
 {
     return(GameLiftServerAPI.AcceptPlayerSession(playerSessionId));
 }
    private bool AcceptPlayer(string playerSessionId)
    {
        var result = GameLiftServerAPI.AcceptPlayerSession(playerSessionId);

        return(result.Success);
    }