PresenceList: me property

Available since @irtio/client 5.0BrowsersNode

The me read-only property of the PresenceList interface is the local player’s presence entry.

Value

A PresenceEntry, or undefined before the client is first ready. It’s the same entry as room.presence.get(room.player).

Description

setStatus() changes me.status at once, before the room has the new status. Every other client sees it once the room has applied it.

Examples

Showing the player’s own name

The room sets each player’s name. The client shows its own, or its player ID until the room has named it.

// me.ts
import { connect } from "@irtio/client";

const room = await connect("main");

room.presence.addEventListener("change", ({ entry, changed }) => {
  if (entry === room.presence.me && changed.includes("name")) console.log(`playing as ${entry.name}`);
});
console.log(`playing as ${room.presence.me?.name || room.player}`);

See also

Runtime availability

BrowsersNode
me5.05.0