[GameLift][FlexMatch] Update session interface for clients to make matchmaking requests (#4450)

* [GameLift][FlexMatch] Update session interface for clients to make matchmaking requests

Signed-off-by: Junbo Liang <junbo@amazon.com>
This commit is contained in:
Junbo Liang
2021-10-06 10:56:49 -07:00
committed by GitHub
parent 0848a9cdf9
commit 4f51b53558
24 changed files with 885 additions and 131 deletions
@@ -0,0 +1,29 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AzFramework/Matchmaking/MatchmakingRequests.h>
namespace AWSGameLift
{
//! AWSGameLiftAcceptMatchRequest
//! GameLift accept match request which corresponds to Amazon GameLift
//! Registers a player's acceptance or rejection of a proposed FlexMatch match.
//! AcceptMatchRequest
struct AWSGameLiftAcceptMatchRequest
: public AzFramework::AcceptMatchRequest
{
public:
AZ_RTTI(AWSGameLiftAcceptMatchRequest, "{8372B297-88E8-4C13-B31D-BE87236CA416}", AzFramework::AcceptMatchRequest);
static void Reflect(AZ::ReflectContext* context);
AWSGameLiftAcceptMatchRequest() = default;
virtual ~AWSGameLiftAcceptMatchRequest() = default;
};
} // namespace AWSGameLift
@@ -8,7 +8,7 @@
#pragma once
#include <AzFramework/Session/ISessionRequests.h>
#include <AzFramework/Session/SessionRequests.h>
namespace AWSGameLift
{
@@ -8,7 +8,7 @@
#pragma once
#include <AzFramework/Session/ISessionRequests.h>
#include <AzFramework/Session/SessionRequests.h>
namespace AWSGameLift
{
@@ -8,7 +8,7 @@
#pragma once
#include <AzFramework/Session/ISessionRequests.h>
#include <AzFramework/Session/SessionRequests.h>
namespace AWSGameLift
{
@@ -8,7 +8,7 @@
#pragma once
#include <AzFramework/Session/ISessionRequests.h>
#include <AzFramework/Session/SessionRequests.h>
namespace AWSGameLift
{
@@ -0,0 +1,59 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AzFramework/Matchmaking/MatchmakingRequests.h>
namespace AWSGameLift
{
//! AWSGameLiftPlayerInformation
//! Information on each player to be matched
//! This information must include a player ID, and may contain player attributes and latency data to be used in the matchmaking process
//! After a successful match, Player objects contain the name of the team the player is assigned to
struct AWSGameLiftPlayerInformation
{
AZ_RTTI(AWSGameLiftPlayerInformation, "{B62C118E-C55D-4903-8ECB-E58E8CA613C4}");
static void Reflect(AZ::ReflectContext* context);
AWSGameLiftPlayerInformation() = default;
virtual ~AWSGameLiftPlayerInformation() = default;
// A map of region names to latencies in millseconds, that indicates
// the amount of latency that a player experiences when connected to AWS Regions
AZStd::unordered_map<AZStd::string, int> m_latencyInMs;
// A collection of key:value pairs containing player information for use in matchmaking
// Player attribute keys must match the playerAttributes used in a matchmaking rule set
// Example: {"skill": "{\"N\": \"23\"}", "gameMode": "{\"S\": \"deathmatch\"}"}
AZStd::unordered_map<AZStd::string, AZStd::string> m_playerAttributes;
// A unique identifier for a player
AZStd::string m_playerId;
// Name of the team that the player is assigned to in a match
AZStd::string m_team;
};
//! AWSGameLiftStartMatchmakingRequest
//! GameLift start matchmaking request which corresponds to Amazon GameLift
//! Uses FlexMatch to create a game match for a group of players based on custom matchmaking rules
//! StartMatchmakingRequest
struct AWSGameLiftStartMatchmakingRequest
: public AzFramework::StartMatchmakingRequest
{
public:
AZ_RTTI(AWSGameLiftStartMatchmakingRequest, "{D273DF71-9C55-48C1-95F9-8D7B66B9CF3E}", AzFramework::StartMatchmakingRequest);
static void Reflect(AZ::ReflectContext* context);
AWSGameLiftStartMatchmakingRequest() = default;
virtual ~AWSGameLiftStartMatchmakingRequest() = default;
// Name of the matchmaking configuration to use for this request
AZStd::string m_configurationName;
// Information on each player to be matched
AZStd::vector<AWSGameLiftPlayerInformation> m_players;
};
} // namespace AWSGameLift
@@ -0,0 +1,29 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AzFramework/Matchmaking/MatchmakingRequests.h>
namespace AWSGameLift
{
//! AWSGameLiftStopMatchmakingRequest
//! GameLift stop matchmaking request which corresponds to Amazon GameLift
//! Cancels a matchmaking ticket or match backfill ticket that is currently being processed.
//! StopMatchmakingRequest
struct AWSGameLiftStopMatchmakingRequest
: public AzFramework::StopMatchmakingRequest
{
public:
AZ_RTTI(AWSGameLiftStopMatchmakingRequest, "{2766BC03-9F84-4346-A52B-49129BBAF38B}", AzFramework::StopMatchmakingRequest);
static void Reflect(AZ::ReflectContext* context);
AWSGameLiftStopMatchmakingRequest() = default;
virtual ~AWSGameLiftStopMatchmakingRequest() = default;
};
} // namespace AWSGameLift
@@ -11,6 +11,7 @@
#include <AzCore/EBus/EBus.h>
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/std/string/string.h>
#include <AzFramework/Matchmaking/IMatchmakingRequests.h>
#include <AzFramework/Session/ISessionRequests.h>
namespace AWSGameLift
@@ -71,4 +72,26 @@ namespace AWSGameLift
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
};
using AWSGameLiftSessionRequestBus = AZ::EBus<AzFramework::ISessionRequests, AWSGameLiftSessionRequests>;
// IMatchmakingAsyncRequests EBus wrapper for scripting
class AWSGameLiftMatchmakingAsyncRequests
: public AZ::EBusTraits
{
public:
using MutexType = AZStd::recursive_mutex;
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
};
using AWSGameLiftMatchmakingAsyncRequestBus = AZ::EBus<AzFramework::IMatchmakingAsyncRequests, AWSGameLiftMatchmakingAsyncRequests>;
// IMatchmakingRequests EBus wrapper for scripting
class AWSGameLiftMatchmakingRequests
: public AZ::EBusTraits
{
public:
using MutexType = AZStd::recursive_mutex;
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
};
using AWSGameLiftMatchmakingRequestBus = AZ::EBus<AzFramework::IMatchmakingRequests, AWSGameLiftMatchmakingRequests>;
} // namespace AWSGameLift