PlayMesh/Docs
HomeGitHubnpm

Presence

Live join/leave events, member snapshots, and cross-node session lookup.

Overview

Joins and leaves are broadcast to instance members in real time, and join snapshots include the current member list - every client always knows who is in each of its instances, without any application code.

On the client

client.presenceOf('world/city');   // { count, users }
client.onPresence(event => {
  // { instance, type: 'join' | 'leave', userId, sessionId, count }
});

On the server

await city.memberCount();          // total members across all nodes
await mesh.sessionsOf('alice');    // all session ids of a user across nodes
instance.sessions is local-node only. Use instance.memberCount() for the cluster total.

Multi-node self-healing

In multi-node (Redis) deployments, nodes heartbeat their sessions and periodically sweep ghost sessions left behind by crashed nodes, so presence counts self-heal without manual intervention.