I am using Unity and trying to achieve the following server+matchmaking setup
- Two (or more) players match, server is created. Max game size of say, 32
- Server creates a backfill ticket to find more players.
- Once the backfill ticket is matched, server makes another backfill ticket.
- Server repeats this process until the max player count is reached.
I have steps 1 and 2 working, I am able to match two players, create a backfill ticket, and a 3rd player is able to connect.
However, once the 3rd player connects, I have been unable to add additional players. The server error logs report "CreateServerBackfillTicket: User is a member of too many backfill tickets." in response to trying to create additional backfill tickets from the server, once the first backfill ticket has been matched.
A couple of questions:
Does the ServerBackfillTicket get removed from the queue once it is matched and the player is added,
or is further action needed from the server before it can submit an additional backfill ticket?
Does the server need to poll GetServerBackfillTicketRequest every 6 seconds like a regular client matchmaking ticket? Can a server poll more often? (Is polling even neccessary, can I just wait for the callback to be invoked?)
The relevant code snippets are below:
PlayFabMultiplayerAgentAPI calls OnServerActive,
private void OnServerActive() { var titleEntity = new EntityKey(PlayFabSettings.TitleId, "title"); var entityRequest = new GetEntityTokenRequest() { Entity = titleEntity }; PlayFabAuthenticationAPI.GetEntityToken(entityRequest, OnGetEntityToken, UpdateMessageError); }
This calls OnGetEntityToken,
private void OnGetEntityToken(GetEntityTokenResponse result) { var matchId = PlayFabMultiplayerAgentAPI.SessionConfig.SessionId; var getMatchRequest = new GetMatchRequest() { MatchId = matchId, QueueName = queueName, ReturnMemberAttributes = true }; PlayFabMultiplayerAPI.GetMatch(getMatchRequest, OnGetMatchServer, Debug.LogError); }
Which calls OnGetMatchServer,
private void OnGetMatchServer(GetMatchResult result) { var backfillRequest = new CreateServerBackfillTicketRequest() { GiveUpAfterSeconds = backfillTimeout, Members = result.Members, QueueName = queueName, ServerDetails = result.ServerDetails }; PlayFabMultiplayerAPI.CreateServerBackfillTicket(backfillRequest, createResult => StartCoroutine(OnCreateServerBackfillTicket(createResult)), UpdateMessageError); }
Then starts coroutine OnCreateServerBackfill Ticket
private IEnumerator OnCreateServerBackfillTicket(CreateServerBackfillTicketResult result) { serverWaitingForMatch = true; while (serverWaitingForMatch) { var request = new GetServerBackfillTicketRequest() { QueueName = queueName, TicketId = result.TicketId }; PlayFabMultiplayerAPI.GetServerBackfillTicket(request, OnGetServerBackfillTicket, UpdateMessageError); // Can poll up to 10 times per minute on client, not sure about server though yield return new WaitForSeconds(6); } }
Which then polls the ServerBackfillTicketrequest every 6 seconds, and calls OnGetServerBackfillTicket
private void OnGetServerBackfillTicket(GetServerBackfillTicketResult result) { if (result.Status != "Canceled" && result.Status != "Matched") { return; } // This will stop the polling coroutine serverWaitingForMatch = false; // Create a new backfill ticket request var matchId = PlayFabMultiplayerAgentAPI.SessionConfig.SessionId; var getMatchRequest = new GetMatchRequest() { MatchId = matchId, QueueName = queueName, ReturnMemberAttributes = true }; PlayFabMultiplayerAPI.GetMatch(getMatchRequest, OnGetMatchServer, Debug.LogError); }
Which checks to see if the result is cancelled or matched, and if so, begins the process again by calling OnGetMatchServer (Above)
Hopefully this is enough info.
To summarise, I am mostly looking for the intended way to create a backfill ticket, and then once that ticket has been matched, create additioanl tickets if neccessary to achieve the desired player count. (I want players to be able to join one by one, rather than waiting for a large group of players to be able to join the game)
If there was an example showing how to proeprly use Server backfill tickets, I'm sure many others would also find it useful.
Thanks for any help!