# RoomOpenEvent

> The RoomOpenEvent interface of the Client API is the event a RoomClient fires as open, when it holds the room's full state after having no connection.

The **`RoomOpenEvent`** interface of the [Client API](/docs/client) is the event a [`RoomClient`](/docs/client/room-client) fires as its [`open` event](/docs/client/room-client/open-event), when it holds the room's full state after having no connection. It extends `Event`.

## Constructor

```ts
new RoomOpenEvent(reconnected)
```

`reconnected`
: A boolean, the event's `reconnected`. The event's type is `"open"`.

The client creates the events it fires.

## Instance properties

All are read only. It also has `Event`'s properties, such as `type`.

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

## Examples

### Counting reconnects

A game's debug overlay counts how often the client has reconnected.

```ts
// reconnects.ts
import { connect, type RoomOpenEvent } from "@irtio/client";

const room = await connect("https://rooms.irt.io/my-game/arena");
let reconnects = 0;

function opened(event: RoomOpenEvent): void {
  if (event.reconnected) reconnects += 1;
  console.log(`reconnects: ${reconnects}`);
}
room.addEventListener("open", opened);
```

## See also

- [`open` event](/docs/client/room-client/open-event)
- [`RoomCloseEvent`](/docs/client/room-close-event)
- [Client API on one page](/docs/client/one-page#roomclient), the whole of `@irtio/client` on one page
