heroiclabs / nakama-unity

Unity client for Nakama server.
https://heroiclabs.com/docs/unity-client-guide
Other
411 stars 75 forks source link

ISocket.SendMatchStateAsync() recipients confusion #84

Closed ReGaSLZR closed 4 years ago

ReGaSLZR commented 4 years ago

Hello again, guys :wave:

About my issue: https://github.com/heroiclabs/nakama-unity/issues/83 and forum post: https://forum.heroiclabs.com/t/sendmatchstateasync-for-all-players-including-the-sender/363

Here are Yes / No simplified questions:

[1] On the

ISocket.SendMatchStateAsync (string matchId, long opCode, byte[] state, IEnumerable<IUserPresence> presences = null);

Is the presences parameter a list of users (in the same match) who will receive the match state code?

[2] Does the match have to be marked authoritative=True for the state code to be broadcast to ALL users (including the sender)?

ReGaSLZR commented 4 years ago

To anyone getting stuck in this:

It's not noted anywhere in the docs but it seems this overload of ISocket.SendMatchStateAsync() (with the list of recipients as a param) does not work as a broadcast to all users, unless in your server, you imported/included content for function M.match_loop (please see: the sample in https://heroiclabs.com/docs/gameplay-multiplayer-server-multiplayer/#full-example )

With the help of my team's awesome server/backend engineer, we made the SendMatchStateAsync to all connected users (including the sender) possible.

Just a note: Nakama's exposed overload of ISocket with the list of User Presences as a param

SendMatchStateAsync (string matchId, long opCode, byte[] state, IEnumerable<IUserPresence> presences = null);

does NOT work out-of-the-box as a broadcast to all connected clients.

zyro commented 4 years ago

See #83.

mofirouz commented 4 years ago

This is not an issue with Nakama or Nakama-Unity client.

I've written a more comprehensive, and correct answer on the forum post here: https://forum.heroiclabs.com/t/sendmatchstateasync-for-all-players-including-the-sender/363/4