# PresenceEntry

> The PresenceEntry interface of the Room API is one player's presence, with its player ID, name, status and whether it's connected.

The **`PresenceEntry`** interface of the [Room API](/docs/room) is one player's [presence](/docs/room/presence): its player ID, name and status, and whether it has an open connection. Every connection sees the same entry.

[`Presence.get()`](/docs/room/presence/get) returns one, and iterating `room.presence` visits each. Its properties are read only, and show the entry's current values; change the name and status with [`Presence.set()`](/docs/room/presence/set).

## Instance properties

`PresenceEntry.player`
: The player ID, the same as [`Connection.player`](/docs/room/connection/player) for the player's connections. For a bot, its bot ID.

`PresenceEntry.name`
: A string of at most `MAX_PRESENCE_NAME` (64) characters, which the room sets. It starts as the `name` string of the token's `meta`, when there's one of at most 64 characters, and `""` otherwise.

`PresenceEntry.status`
: A JSON value of at most `MAX_PRESENCE_STATUS` (1,024) bytes as JSON, which the player sets from its client and the room may replace. `null` until set.

`PresenceEntry.connected`
: A boolean. `false` while the player has no open connection, from just after its last one closes until its entry goes `PRESENCE_GRACE` (10 seconds) later; `true` otherwise, and always for a bot.

## Examples

### Tidying statuses players leave behind

A player who drops keeps its entry for 10 seconds. This room clears a "typing" status as soon as the player is gone.

```ts
// typing.ts
import { defineRoom } from "@irtio/room";

export default defineRoom({
  tickRate: 2,
  onTick(room) {
    for (const entry of room.presence) {
      const status = entry.status as { typing?: boolean } | null;
      if (!entry.connected && status?.typing) room.presence.set(entry.player, { status: null });
    }
  },
});
```

## See also

- [`Presence`](/docs/room/presence)
- [An entry](/docs/room/guides/presence#an-entry)
