Questions regarding SendMatchStateAsync

While using SendMatchStateAsync socket function some questions came to my mind:

  1. What does the final argument “presences” mean? (not used in the docs)
  2. The function returns a Task. What is it for? does it expect some answer to be returned from the server?
  3. Does the data send to the server (if done in JSON format) need to be escaped?
  4. Can I send empty strings? Sometimes I don’t really need to send any data, just the OP code to execute the appropriate command…

@reverso13 I can help with these questions.

What does the final argument “presences” mean? (not used in the docs)

The client can send messages to specific presences. This is the term we use for a player who’s connected to a match. If that argument is null it will send the message to all players. This is only useful if the match is client-relayed where the game client decides who to send messages to. In authoritative matches the messages will always be sent to the match handler.

The function returns a Task. What is it for? does it expect some answer to be returned from the server?

This is leftover from an older version of the client sdk. We always strive to maintain backwards compatibility but the send is non-blocking so the task returned is actually always “completed” already:

https://github.com/heroiclabs/nakama-dotnet/blob/master/src/Nakama/Socket.cs#L408

Does the data send to the server (if done in JSON format) need to be escaped?

The client sends bytes to the server so it can use whatever format you like. The JSON doesn’t need to be escaped if you choose to use JSON.

Can I send empty strings? Sometimes I don’t really need to send any data, just the OP code to execute the appropriate command…

Sure you can. In fact this is a great question because we should cover it in the docs. Using just opcodes is great as “command messages” sent to the match handler.

Hope this helps.