heroiclabs / nakama-godot

Godot client for Nakama server written in GDScript.
Apache License 2.0
593 stars 69 forks source link

Party presence event is not received by client when party is created #193

Closed jonbonazza closed 8 months ago

jonbonazza commented 8 months ago

On the nakama runtime logs, I see the following after creating a party from a Godot client:

emergence-nakama-nakama-1  | {"level":"debug","ts":"2023-12-31T10:13:29.554Z","caller":"server/tracker.go:907","msg":"Processing presence event","joins":1,"leaves":0}

I have a the received_party_presence signal connected on the client but it is never called.

This is using the lastestGodot 4 client on the Godot asset lib (running on Windows 11), and nakama version 3.20.0 running in a docker container.

novabyte commented 8 months ago

@jonbonazza When you call the socket function for creating a party can you print what the contents of the structure you get back looks like?

jonbonazza commented 8 months ago

@jonbonazza When you call the socket function for creating a party can you print what the contents of the structure you get back looks like?

Okay so finally had some more time to look at this, it looks like I get a NakamaRTAPI.Party struct and it does indeed have the leader and current party presences (which in my case, just has the one member). So I guess my questions then are:

  1. Do I not get a presence event with the leader on party create? I only get that info in the response? This is fine if it's the case, just wanted to make sure I understand it correctly.
  2. In the Party struct, presences is an array of UserPresence objects. Is there ever a situation where this array will have more than one item in it in the case of party creation? I'm assuming this is just an array because the class is reused in other places as well in during party creation, this array will always have exactly one entry, is that correct?
novabyte commented 8 months ago

Do I not get a presence event with the leader on party create? I only get that info in the response? This is fine if it's the case, just wanted to make sure I understand it correctly.

@jonbonazza When one of the realtime features of Nakama is used they all share the same structural pattern of an initial state is returned (in the case of Parties its NakamaRTAPI.Party) and deltas (joins and leaves) which will be received from the event listeners (i.e. received_party_presence signal). Together it provides the most compact way to keep track of presences in that gameplay feature. When a Party is created the leader receives the initial state but will not also receive a signal on received_party_presence.

Is there ever a situation where this array will have more than one item in it in the case of party creation? I'm assuming this is just an array because the class is reused in other places as well in during party creation, this array will always have exactly one entry, is that correct?

The system is designed to batch presence changes so its possible (though in the case of Party creation - it would be a very small window of time) that the party is created and another player finds it to join (if its an open party) before the party creator then receives their NakamaRTAPI.Party struct response. In this case it would be practically unlikely to occur but the design must account for it anyway to avoid potential race conditions.

Can we move the follow on questions to a forum thread? 🙏

Hope this helps.