/// <summary> /// Get a matchmaking ticket by ticket Id. /// </summary> public static void GetMatchmakingTicket(GetMatchmakingTicketRequest request, Action <GetMatchmakingTicketResult> resultCallback, Action <PlayFabError> errorCallback, object customData = null, Dictionary <string, string> extraHeaders = null) { var context = (request == null ? null : request.AuthenticationContext) ?? PlayFabSettings.staticPlayer; PlayFabHttp.MakeApiCall("/Match/GetMatchmakingTicket", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context); }
private static async Task <bool> WaitForTicket(Player player, string mmQueueName) { var getTicketRequest = new GetMatchmakingTicketRequest { TicketId = player.mmTicketId, QueueName = mmQueueName // Why isn't this discoverable from the ticketId? }; bool success = false; for (int i = 0; i < 10; i++) { PlayFabResult <GetMatchmakingTicketResult> ticketResult = await player.mpApi.GetMatchmakingTicketAsync(getTicketRequest); GetMatchmakingTicketResult ticket = VerifyPlayFabCall(ticketResult, "Matchmake ticket poll failed."); if (ticket.Status == "Matched") { player.mmMatchId = ticket.MatchId; player.ticket = ticket; success = true; break; } System.Threading.Thread.Sleep(6000); // "WaitingForMatch", "Matched" } VerifySuccess(success, $"Matchmake for {player.context.PlayFabId}"); return(success); }
/// <summary> /// Get a matchmaking ticket by ticket Id. /// </summary> public void GetMatchmakingTicket(GetMatchmakingTicketRequest request, Action <GetMatchmakingTicketResult> resultCallback, Action <PlayFabError> errorCallback, object customData = null, Dictionary <string, string> extraHeaders = null) { var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext; var callSettings = apiSettings ?? PlayFabSettings.staticSettings; if (!context.IsEntityLoggedIn()) { throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn, "Must be logged in to call this method"); } PlayFabHttp.MakeApiCall("/Match/GetMatchmakingTicket", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this); }
private IEnumerator PollTicket() { while (true) { var request = new GetMatchmakingTicketRequest { TicketId = ticketId, QueueName = PlayfabUtils.MATCHMAKING_NAME }; PlayFabMultiplayerAPI.GetMatchmakingTicket(request, OnTicketGet, OnError); yield return(new WaitForSeconds(PlayfabUtils.MATCHMAKING_POLL_INTERVAL)); } }
/// <summary> /// Get a matchmaking ticket by ticket Id. /// </summary> public static void GetMatchmakingTicket(GetMatchmakingTicketRequest request, Action <GetMatchmakingTicketResult> resultCallback, Action <PlayFabError> errorCallback, object customData = null, Dictionary <string, string> extraHeaders = null) { PlayFabHttp.MakeApiCall("/Match/GetMatchmakingTicket", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders); }