question

DP avatar image
DP asked

Best way to use Matchmaking infrastructure to power "Room Codes"

We're developing a multiplayer experience where players can "Host a new game" and we'd like to give them a room code (6 random hexadecimal characters) that they can share with their friends to join.

Should we be using the matchmaking infrastructure for this? If so, what would the workflow look like from a PlayFab API perspective?

Matchmakingmultiplayer
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Sarah Zhang avatar image
Sarah Zhang answered

Do you mean you want to implement a Matchmaking mechanism that the players holding the same “room code” can be matched with each other? If so, you can consider using MatchMaking with StringEqualityRule. String equality rule can ensure all tickets in a match have the same string attribute. So, you can use this rule to match the players holding the same code. Assuming you use PlayFab Multiplayer Server Service to host the multiplayer server. The possible workflow would be something like this.

  1. The “Room creator” invoke the RequestMultiplayerServer to request a PlayFab Multiplayer Server instance. The server generates a random room code.
  2. The server calls the CreateServerBackfillTicket, uses the above room code as the attribute value, and fills its own IP and Port in the request body.
  3. The room creator’s friend calls the CreateMatchmakingTicket, also uses the room code as the attribute value.
  4. The room creator’s friend loops the GetMatchmakingTicket until the ticket matched.
  5. After the ticket matched, the friend calls the GetMatch to get the server instance’s IP and Port to connect to it.
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

DP avatar image DP commented ·

OK great! That was my initial thinking as well, glad to hear I was on the right path.

One thing: Instead of having the creator called RequestMultiplayerServer first, I was thinking of calling CreateServerMatchmakingTicket w/ a queue that has "enable server allocation" set. As I create that ticket, I was planning to generate the code and associate it with the ticket using the StringEqualityRule there.

Would this also work? Figured, it might save an RPC from my end. WDYT?

0 Likes 0 ·
DP avatar image DP commented ·

When I add the creator to the backfill ticket, do I need to also call JoinMatchmakingTicket for the creator? Or is it assumed their prejoined if specified in the request members field of CreateServerBackfillTicket?

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Error rendering WebPanel (widgets/consolidation-widget.ftl): org.hibernate.hql.internal.ast.QuerySyntaxException: AvailableConsolidation is not mapped [from AvailableConsolidation up where up.node = :node]