gpg:: TurnBasedMultiplayerManager
#include <turn_based_multiplayer_manager.h>
获取、修改和创建 TurnBasedMatch
对象。
摘要
公共类型 |
|
---|---|
MatchInboxUICallback
|
typedefstd::function< void(const MatchInboxUIResponse &)>
定义可以从 ShowMatchInboxUI 接收 MatchInboxUIResponse 的回调。 |
MultiplayerStatusCallback
|
typedefstd::function< void(MultiplayerStatus)>
定义可用于接收 MultiplayerStatus 的回调。 |
PlayerSelectUICallback
|
typedefstd::function< void(const PlayerSelectUIResponse &)>
定义可以从 ShowPlayerSelectUI 接收 PlayerSelectUIResponse 的回调。 |
TurnBasedMatchCallback
|
typedefstd::function< void(const TurnBasedMatchResponse &)>
定义一个回调,可用于从某个回合制多人游戏操作接收 TurnBasedMatchResponse 。 |
TurnBasedMatchesCallback
|
typedefstd::function< void(const TurnBasedMatchesResponse &)>
定义可从某个回合制多人游戏操作接收 TurnBasedMatchesResponse 的回调。 |
公共静态属性 |
|
---|---|
kAutomatchingParticipant
|
const MultiplayerParticipant
可传递给接受“下一个参与者”的方法的参与者。
|
结构体 |
|
---|---|
gpg:: |
|
gpg:: |
|
gpg:: |
针对特定 |
gpg:: |
|
公共类型
MatchInboxUICallback
std::function< void(const MatchInboxUIResponse &)> MatchInboxUICallback
定义可以从 ShowMatchInboxUI
接收 MatchInboxUIResponse
的回调。
MultiplayerStatusCallback
std::function< void(MultiplayerStatus)> MultiplayerStatusCallback
定义可用于接收 MultiplayerStatus 的回调。
由 LeaveMatch 和 CancelMatch 函数使用。
PlayerSelectUICallback
std::function< void(const PlayerSelectUIResponse &)> PlayerSelectUICallback
定义可以从 ShowPlayerSelectUI
接收 PlayerSelectUIResponse
的回调。
TurnBasedMatchCallback
std::function< void(const TurnBasedMatchResponse &)> TurnBasedMatchCallback
定义一个回调,可用于从某个回合制多人游戏操作接收 TurnBasedMatchResponse
。
TurnBasedMatchesCallback
std::function< void(const TurnBasedMatchesResponse &)> TurnBasedMatchesCallback
定义可从某个回合制多人游戏操作接收 TurnBasedMatchesResponse
的回调。
公共静态属性
kAutomatchingParticipant
const MultiplayerParticipant kAutomatchingParticipant
可传递给接受“下一个参与者”的方法的参与者。
这样,该方法就会通过自动匹配功能选择下一位参与者。仅当相关匹配的 TurnBasedMatch::AutomatchingSlotsAvailable 大于 0 时,将 kAutomatchingCharacter 传递给函数才有效。
公共函数
AcceptInvitation
void AcceptInvitation( const MultiplayerInvitation & invitation, TurnBasedMatchCallback callback )
异步接受 MultiplayerInvitation
,并通过 TurnBasedMatchCallback
返回结果。
如果操作成功,通过回调返回的 TurnBasedMatch
将处于 TurnBasedMatchState::MY_TURN
状态。
AcceptInvitationBlocking
TurnBasedMatchResponse AcceptInvitationBlocking( Timeout timeout, const MultiplayerInvitation & invitation )
AcceptInvitation 的屏蔽版本。
允许调用方指定超时(以毫秒为单位)。在指定的时间过后,该函数会返回 ERROR_TIMEOUT
。
AcceptInvitationBlocking
TurnBasedMatchResponse AcceptInvitationBlocking( const MultiplayerInvitation & invitation )
AcceptInvitationBlocking 过载,它使用默认超时时间(10 年)。
CancelMatch
void CancelMatch( const TurnBasedMatch & match, MultiplayerStatusCallback callback )
异步取消匹配。
通过 MultiplayerStatusCallback
返回的状态指示操作是否成功。匹配状态必须为 INVITED、THEIR_TURN 或 MY_TURN,此函数才能使用。
CancelMatchBlocking
MultiplayerStatus CancelMatchBlocking( Timeout timeout, const TurnBasedMatch & match )
CancelMatch 的屏蔽版本。
允许调用方指定超时(以毫秒为单位)。在指定的时间过后,该函数会返回 ERROR_TIMEOUT
。
CancelMatchBlocking
MultiplayerStatus CancelMatchBlocking( const TurnBasedMatch & match )
CancelMatch 过载,默认超时时间为 10 年。
ConfirmPendingCompletion
void ConfirmPendingCompletion( const TurnBasedMatch & match, TurnBasedMatchCallback callback )
确认已结束且正在等待本地完成的匹配结果。
仅当 TurnBasedMatch::Status()
返回 MatchStatus::PENDING_COMPLETION
时,才能调用此函数。
具体说明 | |||||
---|---|---|---|---|---|
参数 |
|
ConfirmPendingCompletionBlocking
TurnBasedMatchResponse ConfirmPendingCompletionBlocking( Timeout timeout, const TurnBasedMatch & match )
ConfirmPendingCompletion 的阻止版本。
允许调用方指定超时(以毫秒为单位)。在指定的时间过后,该函数会返回 ERROR_TIMEOUT
。
ConfirmPendingCompletionBlocking
TurnBasedMatchResponse ConfirmPendingCompletionBlocking( const TurnBasedMatch & match )
ConfirmPendingCompletionBlocking 的过载,使用默认的超时时间(10 年)。
CreateTurnBasedMatch
void CreateTurnBasedMatch( const gpg::TurnBasedMatchConfig & config, TurnBasedMatchCallback callback )
使用提供的 TurnBasedMatchConfig
异步创建 TurnBasedMatch
。
如果创建成功,此函数会通过提供的 TurnBasedMatchCallback
返回 TurnBasedMatch
。新创建的 TurnBasedMatch
始终以 TurnBasedMatchState::MY_TURN
状态开始。
CreateTurnBasedMatchBlocking
TurnBasedMatchResponse CreateTurnBasedMatchBlocking( Timeout timeout, const gpg::TurnBasedMatchConfig & config )
CreateTurnBasedMatch 的屏蔽版本。
允许调用方指定超时(以毫秒为单位)。在指定的时间过后,该函数会返回 ERROR_TIMEOUT
。
CreateTurnBasedMatchBlocking
TurnBasedMatchResponse CreateTurnBasedMatchBlocking( const gpg::TurnBasedMatchConfig & config )
CreateTurnBasedMatchBlocking 的过载,它使用默认超时时间(10 年)。
DeclineInvitation
void DeclineInvitation( const MultiplayerInvitation & invitation )
拒绝向 TurnBasedMatch
发出的 MultiplayerInvitation
。
这样做会取消其他参与者的对局,并从本地玩家的设备中移除该对局。
DismissInvitation
void DismissInvitation( const MultiplayerInvitation & invitation )
关闭对 TurnBasedMatch
的 MultiplayerInvitation
。
这不会更改其他参与者的 TurnBasedMatch
的可见状态,但会从本地玩家的设备中移除 TurnBasedMatch
。
DismissMatch
void DismissMatch( const TurnBasedMatch & match )
关闭 TurnBasedMatch
。
这不会更改其他参与者的 TurnBasedMatch
的可见状态,但会从本地玩家的设备中移除 TurnBasedMatch
。
FetchMatch
void FetchMatch( const std::string & match_id, TurnBasedMatchCallback callback )
按 ID 异步提取特定匹配项。
此操作的结果通过 TurnBasedMatchCallback
返回。
FetchMatchBlocking
TurnBasedMatchResponse FetchMatchBlocking( Timeout timeout, const std::string & match_id )
FetchMatch 的屏蔽版本。
允许调用方指定超时(以毫秒为单位)。在指定的时间过后,该函数会返回 ERROR_TIMEOUT
。
FetchMatchBlocking
TurnBasedMatchResponse FetchMatchBlocking( const std::string & match_id )
FetchMatchBlocking 的过载,它使用默认的超时时间为 10 年。
FetchMatches
void FetchMatches( TurnBasedMatchesCallback callback )
异步提取当前播放器的 TurnBasedMatch
和 Invitation
对象。
返回所有有效匹配和最多 10 个已完成匹配。
FetchMatchesBlocking
TurnBasedMatchesResponse FetchMatchesBlocking( Timeout timeout )
FetchMatches 的屏蔽版本。
允许调用方指定超时(以毫秒为单位)。在指定的时间过后,该函数会返回 ERROR_TIMEOUT
。
FetchMatchesBlocking
TurnBasedMatchesResponse FetchMatchesBlocking()
FetchMatchesBlocking 的过载,默认超时时间为 10 年。
FinishMatchDuringMyTurn
void FinishMatchDuringMyTurn( const TurnBasedMatch & match, std::vector< uint8_t > match_data, const ParticipantResults & results, TurnBasedMatchCallback callback )
异步完成指定的匹配。
在比赛的最后回合期间,可以使用此属性而不是 TakeMyTurn。允许调用方为 match_data
指定最终值,以及为 ParticipantResults
指定一组最终值。完成此操作后,系统将通过提供的 TurnBasedMatchCallback.
返回更新后的匹配项。该函数只能在 TurnBasedMatch::Status()
返回 MatchStatus::MY_TURN.
时调用。
具体说明 | |||||||||
---|---|---|---|---|---|---|---|---|---|
参数 |
|
FinishMatchDuringMyTurnBlocking
TurnBasedMatchResponse FinishMatchDuringMyTurnBlocking( Timeout timeout, const TurnBasedMatch & match, std::vector< uint8_t > match_data, const ParticipantResults & results )
FinishMatchDuringMyTurn 的阻塞版本。
允许调用方指定超时(以毫秒为单位)。在指定的时间过后,该函数会返回 ERROR_TIMEOUT
。
FinishMatchDuringMyTurnBlocking
TurnBasedMatchResponse FinishMatchDuringMyTurnBlocking( const TurnBasedMatch & match, std::vector< uint8_t > match_data, const ParticipantResults & results )
FinishMatchDuringMyTurnBlocking 的过载,其使用默认超时期限(10 年)。
LeaveMatchDuringMyTurn
void LeaveMatchDuringMyTurn( const TurnBasedMatch & match, const MultiplayerParticipant & next_participant, MultiplayerStatusCallback callback )
在本地参与者轮到时异步退出对局。
通过 TurnBasedMatchCallback
返回的响应包含本地玩家离开后的对局状态。如果此次离开导致比赛参与者少于两人,比赛将被取消。match.Status()
必须返回 MatchStatus::MY_TURN
,此函数才可用。
具体说明 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
LeaveMatchDuringMyTurnBlocking
MultiplayerStatus LeaveMatchDuringMyTurnBlocking( Timeout timeout, const TurnBasedMatch & match, const MultiplayerParticipant & next_participant )
LeaveMatchDuringMyTurn 的屏蔽版本。
允许调用方指定超时(以毫秒为单位)。在指定的时间过后,该函数会返回 ERROR_TIMEOUT
。
LeaveMatchDuringMyTurnBlocking
MultiplayerStatus LeaveMatchDuringMyTurnBlocking( const TurnBasedMatch & match, const MultiplayerParticipant & next_participant )
LeaveMatchDuringMyTurnBlocking 的过载,其使用默认超时期(10 年)。
LeaveMatchDuringTheirTurn
void LeaveMatchDuringTheirTurn( const TurnBasedMatch & match, MultiplayerStatusCallback callback )
轮到另一位参赛者时异步退出对局。
通过 MultiplayerStatusCallback
返回的响应包含本地参与者是否已成功退出比赛。如果此次离开导致比赛参与者少于两人,比赛将被取消。match.Status()
必须返回 MatchStatus::THEIR_TURN
,此函数才可用。
LeaveMatchDuringTheirTurnBlocking
MultiplayerStatus LeaveMatchDuringTheirTurnBlocking( Timeout timeout, const TurnBasedMatch & match )
LeaveMatchDuringTheirTurn 的屏蔽版本。
允许调用方指定超时(以毫秒为单位)。在指定的时间过后,该函数会返回 ERROR_TIMEOUT
。
LeaveMatchDuringTheirTurnBlocking
MultiplayerStatus LeaveMatchDuringTheirTurnBlocking( const TurnBasedMatch & match )
LeaveMatchDuringTheirTurnBlocking 的过载,它使用默认的超时时限为 10 年。
再来一局
void Rematch( const TurnBasedMatch & match, TurnBasedMatchCallback callback )
重新匹配状态为 MatchStatus::COMPLETED 的匹配项。
如果可以再匹配,TurnBasedMatchCallback
会收到新的匹配内容。
具体说明 | |||||
---|---|---|---|---|---|
参数 |
|
RematchBlocking
TurnBasedMatchResponse RematchBlocking( Timeout timeout, const TurnBasedMatch & match )
重新匹配的屏蔽版本。
允许调用方指定超时(以毫秒为单位)。在指定的时间过后,该函数会返回 ERROR_TIMEOUT
。
RematchBlocking
TurnBasedMatchResponse RematchBlocking( const TurnBasedMatch & match )
RematchBlocking 的过载,它使用默认的 10 年超时时间。
ShowMatchInboxUI
void ShowMatchInboxUI( MatchInboxUICallback callback )
异步显示对局收件箱界面,允许玩家选择对局或邀请。
完成后,所选匹配项或邀请将通过 MatchInboxUICallback
返回。
ShowMatchInboxUIBlocking
MatchInboxUIResponse ShowMatchInboxUIBlocking( Timeout timeout )
ShowMatchInboxUI 的屏蔽版本。
允许调用方指定超时(以毫秒为单位)。在指定的时间过后,该函数会返回 ERROR_TIMEOUT
。
ShowMatchInboxUIBlocking
MatchInboxUIResponse ShowMatchInboxUIBlocking()
ShowMatchInboxUIBlocking 的过载,它使用默认的超时期限为 10 年。
ShowPlayerSelectUI
void ShowPlayerSelectUI( uint32_t minimum_players, uint32_t maximum_players, bool allow_automatch, PlayerSelectUICallback callback )
异步显示玩家选择界面,允许玩家选择其他玩家来对局。
完成后,系统将通过 PlayerSelectUICallback
返回所选玩家。
ShowPlayerSelectUIBlocking
PlayerSelectUIResponse ShowPlayerSelectUIBlocking( Timeout timeout, uint32_t minimum_players, uint32_t maximum_players, bool allow_automatch )
ShowPlayerSelectUI 的屏蔽版本。
允许调用方指定超时(以毫秒为单位)。在指定的时间过后,该函数会返回 ERROR_TIMEOUT
。
ShowPlayerSelectUIBlocking
PlayerSelectUIResponse ShowPlayerSelectUIBlocking( uint32_t minimum_players, uint32_t maximum_players, bool allow_automatch )
ShowPlayerSelectUIBlocking 的过载,使用默认的 10 年超时时间。
SynchronizeData
void SynchronizeData()
强制与服务器同步 TBMP 匹配数据。
收到新数据会触发 OnTurnBasedMatchEventCallback
或 OnMultiplayerInvitationReceivedCallback
。
TakeMyTurn
void TakeMyTurn( const TurnBasedMatch & match, std::vector< uint8_t > match_data, const ParticipantResults & results, const MultiplayerParticipant & next_participant, TurnBasedMatchCallback callback )
异步轮到本地参与者。
在一个回合中,参与者可以为“match_data
”指定一个新值,以及一组“ParticipantResults
”。轮流结束后,系统会通过 TurnBasedMatchCallback
返回更新后的对局。只有在 TurnBasedMatch::Status()
为 MatchStatus::MY_TURN
时才能调用此函数。
具体说明 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
参数 |
|
TakeMyTurnBlocking
TurnBasedMatchResponse TakeMyTurnBlocking( Timeout timeout, const TurnBasedMatch & match, std::vector< uint8_t > match_data, const ParticipantResults & results, const MultiplayerParticipant & next_participant )
TakeMyTurn 的阻塞版本。
允许调用方指定超时(以毫秒为单位)。在指定的时间过后,该函数会返回 ERROR_TIMEOUT
。
TakeMyTurnBlocking
TurnBasedMatchResponse TakeMyTurnBlocking( const TurnBasedMatch & match, std::vector< uint8_t > match_data, const ParticipantResults & results, const MultiplayerParticipant & next_participant )
TakeMyTurnBlocking 的过载,默认超时时间为 10 年。