question

Greg Quinn avatar image
Greg Quinn asked

Matchmaking : How do I use the SubscribeToMatchmakingResource REST endpoint?

Since my game is cross-platform and on platforms not supported by the Unity Multiplayer SDK, I want to use the REST API to handle my client matchmaking requests.

I want to use the REST API to create a ticket, and ''subscribe" to the ticket status to know when a match is found, but I'm not quite sure how to do this.

I've done a search here and on Google for the SubscribeToMatchmakingResource endpoint but nothing comes up nor any instructions on how I can use it.

How can I know from the client once a match has been created without continuously spamming it with requests?

Thanks

Matchmaking
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

·
Rick Chen avatar image
Rick Chen answered

The matchmaking ticket cannot be subscribed. It is necessary to poll the service by TicketId to access the Status of the ticket in matchmaking. In order to do so, you can call GetMatchmakingTicket. You can poll up to 10 times per minute. For instance, poll for the ticket status every 6 seconds. This is by design, it is not spamming.

When the status of the ticket changes to Matched, your client can stop polling the ticket. From that point on, the ticket will include the MatchId.

For more detail, please refer to this document: Matchmaking quickstart - PlayFab | Microsoft Docs.

1 comment
10 |1200

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

justin-1 avatar image justin-1 commented ·

Then what's the use of the SubscribeToMatchmakingResource API call? What's the ResourceId you're supposed to give?


Right now, when I send this request:

{
  "Type": "MatchTicketStatusChange",
  "ResourceId": "{
                   {Ticket id retrieved from CreateMatchmakingTicket API call}}",
  "SubscriptionVersion": 1,
  "PubSubConnectionHandle": "{
                   {The NewConnectionHandle retrieved from PubSub StartOrRecoverSession}}",
  "EntityKey": {
      "Id": "{
                   {Entity ID of the player}}",
      "Type": "title_player_account"
  }
}


I receive the the following error response:

{
    "code": 400,
    "status": "BadRequest",
    "error": "MatchmakingAttributeInvalid",
    "errorCode": 2046,
    "errorMessage": "ResourceId should be '@me' in MatchInvite and valid format for MatchTicketStatusChange"
}

The PlayFab Postman collection has the same kind of ResourceId as a Ticket ID, so I would assume you should use the Ticket ID. If that's not the case, what ResourceId are you supposed to use?
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.