# RoomClient: open event

> The open event of the RoomClient interface fires when the client holds the room's full state after having no connection.

The **`open`** event of the [`RoomClient`](/docs/client/room-client) interface fires when the client holds the room's full state after having no connection: once before [`connect()`](/docs/client/connect) resolves, and again after every reconnect.

## Syntax

```ts
addEventListener("open", (event) => {})
```

## Event type

A [`RoomOpenEvent`](/docs/client/room-open-event). It extends `Event` and adds this property:

[`reconnected`](/docs/client/room-open-event/reconnected) Read only
: `false` for the first open, `true` after each reconnect.

## Description

The first `open` fires before `connect()` and [`ready`](/docs/client/room-client/ready) resolve, with `reconnected` false, so a listener added after `await connect(...)` sees only reconnects. After a reconnect it fires whether the client resumed or the room sent its state whole. It fires before the [`update` event](/docs/client/room-client/update-event) for the same state update.

Between a drop and the next `open`, the client fires a [`reconnecting` event](/docs/client/room-client/reconnecting-event). A room that wakes from sleep fires a [`wake` event](/docs/client/room-client/wake-event) instead, since the connection never dropped.

After a reconnect's `open`, entities the room sent again are new objects: every entity after a full update, and after a resume those that changed and those the player owns. Look them up again, or rebuild from [`onEnter()`](/docs/client/entity-store/onenter).

## Examples

### Telling the player they're back

A status line set while the client reconnects clears when it holds the room's state again. The first `open` has already fired when `connect()` resolves, so this listener sees only reconnects.

```ts
// back-online.ts
import { connect } from "@irtio/client";

const room = await connect("https://rooms.irt.io/my-game/harbour");
const status = document.querySelector("#status")!;

room.addEventListener("reconnecting", () => {
  status.textContent = "Reconnecting";
});
room.addEventListener("open", (event) => {
  if (!event.reconnected) return;
  status.textContent = "";
  console.log(`back after ${room.joinTime?.ms} ms`);
});
```

After a reconnect, [`joinTime`](/docs/client/room-client/jointime) is the time from the drop to the resync.

## See also

- [`RoomOpenEvent`](/docs/client/room-open-event)
- [`reconnecting` event](/docs/client/room-client/reconnecting-event)
- [`wake` event](/docs/client/room-client/wake-event)
- [Errors and close codes](/docs/client/errors), for which drops the client reconnects after
