asadm / playroom-unity

9 stars 1 forks source link

.Players dictionary should be private #66

Closed asadm closed 1 month ago

asadm commented 1 month ago

What happened?

People should just use OnPlayerJoin callback.

Version

0.0.20

What is your environment?

No response

Link to original discussion

No response

Relevant log output

No response

asadm commented 1 month ago

Can we also add the snippet to keep players array in unity docs?

might be something like:

object[] players = Array.Empty<object>();
...
PlayroomKit.OnPlayerJoin((player) => {
  players.push(player)
  player.OnQuit(() => {
    Debug.Log($"{player.id} quit!");
    players.Where(p => p != player).ToArray();
  });
})
SaadBazaz commented 1 month ago

Will get this done. Is there a better way we could/should handle Players @asadm ? Just wondering, we're currently maintaining it in three places.

(JS side, then Unity side, then Game side)

SaadBazaz commented 1 month ago

I've made a PR for docs (https://github.com/asadm/playroom-docs/pull/43).

@momintlh - Please make the method/field private, in a PR here.

momintlh commented 1 month ago

There was a discussion in discord to use a List / Array instead of the dictionary but still keeping it public. So should I do that or just make it private for now?

SaadBazaz commented 1 month ago

Just private for now. We're providing docs to guide users.

SaadBazaz commented 1 month ago

We will revisit the idea of List / Array in another release.

SaadBazaz commented 1 month ago

Completed in #67

SaadBazaz commented 1 month ago

@asadm Is GetPlayers() supposed to be private?