question

Tim van der Heijden avatar image
Tim van der Heijden asked

PlayFab Party Unity Demo - SendData doesn't work unless delayed?

I'm looking into PlayFab & PlayFab party for Unity and had some issues getting the Demo to work. After configuring PlayFab as noted in the documentation, I was able to create & join a network without any problems. Joining with another client also seemed to work fine. (noted from logging & UI output)

After looking at the code however, it turned out that the sample was also using two SendData calls which should have also been logged & shown in output, but this wasn't the case. I debugged a bit and found out that at the time "OnNetworkJoined" is raised, the "PlayFabMultiplayerManager.Get().RemotePlayers" are still empty! Only after waiting a few seconds does the RemotePlayers populate. Adding a delay between joining & sending the data resulted in the logging that you'd expect.

This is a bit worrying though, because it would mean that OnNetworkJoined is either called too soon and the API isn't actually ready to send messages yet, or there should be another callback for when the API is ready?

https://github.com/playfab/PlayFabPartyUnity

unity3dmultiplayer
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

·
Neils Shi avatar image
Neils Shi answered

I debugged a bit and found out that at the time "OnNetworkJoined" is raised, the "PlayFabMultiplayerManager.Get().RemotePlayers" are still empty! Only after waiting a few seconds does the RemotePlayers populate.

After my research, there is indeed such a problem and I set a delay of 1 second between join and send, then it worked. The OnNetworkJoined was fired at AuthenticateLocalUserComplete, and at this time the "PlayFabMultiplayerManager.Get().RemotePlayers" was not populated. So, we suggest you don't write the send data part in the OnNetworkJoined. If you do need to send data immediately after joining the network, you can wait for PlayFabMultiplayerManager.Get().RemotePlayers to be populated and then send data message.

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.