コード例 #1
0
ファイル: Client.cs プロジェクト: adalves/pong-gamelift-godot
    private void ConnectToSession(GameSession session)
    {
        GD.Print("entering a session");

        if (session == null)
        {
            GD.Print("wtf");
            return;
        }

        CreatePlayerSessionRequest playerSessionRequest = new CreatePlayerSessionRequest()
        {
            GameSessionId = session.GameSessionId,
            PlayerData    = "data",
            PlayerId      = GenerateID()
        };

        try
        {
            CreatePlayerSessionResponse playerSessionResponse = gameLiftClient.CreatePlayerSession(playerSessionRequest);
            InitRealtimeClient(playerSessionResponse.PlayerSession);
        }
        catch (Exception e)
        {
            GD.Print(e);
        }
    }
コード例 #2
0
 public Amazon.GameLift.Model.PlayerSession CreatePlayerSession(Amazon.GameLift.Model.GameSession gsession)
 {
     try
     {
         var cpsreq = new Amazon.GameLift.Model.CreatePlayerSessionRequest();
         cpsreq.GameSessionId = gsession.GameSessionId;
         cpsreq.PlayerId      = playerId;
         Amazon.GameLift.Model.CreatePlayerSessionResponse cpsres = aglc.CreatePlayerSession(cpsreq);
         string psid = cpsres.PlayerSession != null ? cpsres.PlayerSession.PlayerSessionId : "N/A";
         Debug.Log((int)cpsres.HttpStatusCode + " PLAYER SESSION CREATED: " + psid);
         return(cpsres.PlayerSession);
     }
     catch (Amazon.GameLift.Model.InvalidGameSessionStatusException e)
     {
         Debug.Log(e.StatusCode.ToString() + " InvalidGameSessionStatusException: " + e.Message);
         return(null);
     }
 }
コード例 #3
0
    public void FindGameSession()
    {
        Debug.Log("FindGameSessionGameLift");

        //Search for active Game sessions:
        //https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/GameLift/TSearchGameSessionsRequest.html
        var request = new SearchGameSessionsRequest()
        {
            FilterExpression = "hasAvailablePlayerSessions=true",
            FleetId          = staticData.myFleetID,
            Limit            = 20,
            //FilterExpression = "maximumSessions>=10 AND hasAvailablePlayerSessions=true" // Example filter to limit search results
        };

        SearchGameSessionsResponse gameSessionlist = null;

        try
        {
            Debug.Log("Searching for game sessions");
            gameSessionlist = m_Client.SearchGameSessions(request);
            Debug.Log("Done Searching for game sessions");
        }
        catch (Exception ex)
        {
            Handler(ex);
        }
        if (gameSessionlist == null)
        {
            Debug.Log("Unable to search for Game Sessions... What now?");
            //return null;
        }
        else
        {
            myGameSession = gameSessionlist.GameSessions[0];
            Debug.Log(gameSessionlist.GameSessions.Count + " sessions found");
            Debug.Log(gameSessionlist.GameSessions[0].CurrentPlayerSessionCount + " / " +
                      gameSessionlist.GameSessions[0].MaximumPlayerSessionCount +
                      " players in game session");
            //Debug.Log(gameSessionlist.GameSessions[0].
        }
        //Debug.Log(gameSessionlist.GameSessions[0].Port);

        //gameSessionlist.GameSessions[0].


        //m_Client.CreatePlayerSession()

        var request2 = new CreatePlayerSessionRequest()
        {
            GameSessionId = gameSessionlist.GameSessions[0].GameSessionId,
            PlayerData    = "BoltIsBestNetworking",
            PlayerId      = UniqueID
        };

        //  var response2 = m_Client.CreatePlayerSession(request2);


        CreatePlayerSessionResponse SessionResponse = null;

        try
        {
            Debug.Log("Creating player session");
            SessionResponse = m_Client.CreatePlayerSession(request2);
            Debug.Log("Done Creating player session");
        }
        catch (Exception ex)
        {
            Handler(ex);
        }
        if (SessionResponse == null)
        {
            Debug.Log("Where are my dragons???");
            //return null;
        }

        return;
    }