/// <summary> /// Create a matchmaking ticket as a client. /// </summary> public static void CreateMatchmakingTicket(CreateMatchmakingTicketRequest request, Action <CreateMatchmakingTicketResult> resultCallback, Action <PlayFabError> errorCallback, object customData = null, Dictionary <string, string> extraHeaders = null) { var context = (request == null ? null : request.AuthenticationContext) ?? PlayFabSettings.staticPlayer; PlayFabHttp.MakeApiCall("/Match/CreateMatchmakingTicket", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context); }
/// <summary> /// Create a matchmaking ticket as a client. /// </summary> public void CreateMatchmakingTicket(CreateMatchmakingTicketRequest request, Action <CreateMatchmakingTicketResult> 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/CreateMatchmakingTicket", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this); }
private CreateMatchmakingTicketRequest GetCreateRequest(MatchmakingPlayerAttributes attributes) { var request = new CreateMatchmakingTicketRequest { Creator = MatchmakingHelper.GetMatchmakingPlayer(Player, attributes), GiveUpAfterSeconds = QueueConfiguration.GiveUpAfterSeconds, QueueName = QueueConfiguration.QueueName, AuthenticationContext = PlayFabAuthenticationContext }; return(request); }
private static async Task CreateMatchmakeTicket(Player player, string mmQueueName) { var createRequest = new CreateMatchmakingTicketRequest { QueueName = mmQueueName, GiveUpAfterSeconds = 15, Creator = new MatchmakingPlayer { Entity = new PlayFab.MultiplayerModels.EntityKey { Id = player.context.EntityId, Type = player.context.EntityType } } // Why isn't this just the caller? }; PlayFabResult <CreateMatchmakingTicketResult> ticketResult = await player.mpApi.CreateMatchmakingTicketAsync(createRequest); CreateMatchmakingTicketResult ticket = VerifyPlayFabCall(ticketResult, "Failed to create matchmake ticket"); player.mmTicketId = ticket.TicketId; }
private static void JoinMatchmaking(PlayFab.MultiplayerModels.EntityKey entity) { // We're joining a simple 2-player matchmaking queue with no rules or restrictions. var matchMakingRequest = new CreateMatchmakingTicketRequest() { QueueName = "nr_simple", Creator = new MatchmakingPlayer() { Entity = entity }, GiveUpAfterSeconds = 30 }; var match = PlayFabMultiplayerAPI.CreateMatchmakingTicketAsync(matchMakingRequest).Result; if (match.Error != null) { Console.WriteLine($"!!! Matchmaking failed: {match.Error.ErrorMessage}"); } }
public void StartMatchmaking() { PlayfabUtils.OnSuccess(feedbackText, "Matchmaking in progress..."); PlayFabMultiplayerAPI.ListQosServersForTitle(new ListQosServersForTitleRequest(), qosRes => { var qosServer = qosRes.QosServers[0].ServerUrl; var qosRegion = qosRes.QosServers[0].Region; Debug.Log($"Pinging QoS Server {qosServer} at {qosRegion}"); Debug.Log(qosRes.ToJson()); var sw = System.Diagnostics.Stopwatch.StartNew(); var udpPort = 5600; var done = false; while (!done || udpPort > 5610) { try { UdpClient client = new UdpClient(udpPort); client.Connect(qosServer, 3075); byte[] sendBytes = BitConverter.GetBytes(0xFFFF); client.Send(sendBytes, sendBytes.Length); IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Any, 3075); byte[] receiveBytes = client.Receive(ref remoteEndPoint); client.Close(); done = true; } catch (Exception e) { Debug.LogError($"[QoS Ping Error]: {e.Message}"); udpPort++; Debug.Log($"Retrying with port {udpPort}"); } } var pingTime = sw.ElapsedMilliseconds; Debug.Log($"Ping success with {pingTime}ms"); if (udpPort > 5610) { StartMatchmaking(); return; } var request = new CreateMatchmakingTicketRequest { Creator = new MatchmakingPlayer { Entity = new PlayFab.MultiplayerModels.EntityKey { Id = loginManager.playerData.accountInfo.entityId, Type = PlayfabUtils.ENTITY_TYPE }, Attributes = new MatchmakingPlayerAttributes { DataObject = new LatenciesData { Latencies = new List <Latency> { { new Latency { region = qosRegion, latency = pingTime } } } } } }, GiveUpAfterSeconds = PlayfabUtils.MATCHMAKING_TIMEOUT, QueueName = PlayfabUtils.MATCHMAKING_NAME }; PlayFabMultiplayerAPI.CreateMatchmakingTicket(request, OnTicketCreated, OnError); }, OnError); }
/// <summary> /// Create a matchmaking ticket as a client. /// </summary> public static void CreateMatchmakingTicket(CreateMatchmakingTicketRequest request, Action <CreateMatchmakingTicketResult> resultCallback, Action <PlayFabError> errorCallback, object customData = null, Dictionary <string, string> extraHeaders = null) { PlayFabHttp.MakeApiCall("/Match/CreateMatchmakingTicket", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders); }