question

bieberneit avatar image
bieberneit asked

Pub Sub Rest API

Hello everybody, im currently trying to implement the Pub Sub stuff, since im developing for ios and android I need to do it via REST API.

Im really struggling with implementing it due to the lack of Documentation.

I bought the Best HTTP2 asset from the unity asset store to make my life easier, I followed the Documentation (https://benedicht.github.io/BestHTTP-Documentation/pages/best_http2/protocols/signalr_core/PlayFabPubSub.html) but how would I retrieve the response of the negotiate so I can use the accesstoken and the Url? How would I subscribe to the Lobby resource? Does anyone have a code example or some sort of explaination?

multiplayer
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

·
Gosen Gao avatar image
Gosen Gao answered

You don’t have to call Pub Sub - Negotiate - REST API (PlayFab Multiplayer) | Microsoft Learn to get the access token and URL manually. As the note mentions, you can use URL(https://{titleId}.playfabapi.com/pubsub), and EntityToken(refer to LoginResult - EntityTokenResponse) to do the same thing. I don’t have Best HTTP2, but according to HubConnectionBuilderHttpExtensions.WithUrl Method (Microsoft.AspNetCore.SignalR.Client) | Microsoft Learn, the code should be like

 connection = new HubConnectionBuilder() 
 .WithUrl("https://xxxxx.playfabapi.com/PubSub", options =>
 {
     options.Headers.Add("X-EntityToken", token);
 })
 .Build();

For Subscribing to lobby resources, you can refer to Subscribing to resources for real-time notifications - PlayFab | Microsoft Learn.

10 |1200

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

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.