Closed tkbala closed 2 years ago
@tkbala I'm closing this this as it is intended behaviour.
The matchJoinAttempt
is executed once per player attempting to join, while matchJoin
batches multiple joins in a single operation. The data of each player that joined is contained in presences
array, so you should iterate over its entries and handle them accordingly.
Ah ok. Looks like the code in the Typescript documentation can be misleading. This needs to be updated
Also, does presences array contain only the users that joined or does it contain all the users? This is not clear from the documentation
Only the presences that have joined the match. Thank you for pointing out the error in the documentation, we'll fix it soon.
Hi @tkbala we've fixed the docs https://heroiclabs.com/docs/nakama/concepts/server-authoritative-multiplayer/#full-example_2 thanks for reporting 😄
Awesome! Thanks for the quick fix :D
I have a Nakama server setup using TypeScript. I have JS clients which connect successfully to the nakama server. Through seeing the presences in the Nakama's web console, I am able to confirm this.
When I query ctx.userID, in the matchJoin function, it seems to be undefined. Butt I am able to see the userId in the presences array in the matchJoin function, when I print it out. Also, ctx.userId seems to works in the matchJoinAttempt function.
Here's my two functions
Log from the server is below:
I am unsure what is wrong. These are the code that is present at https://heroiclabs.com/docs/nakama/concepts/server-authoritative-multiplayer/
Nakama: 3.4.0
Operating System and version: Ubuntu 20.04