# RoomClient: sleep event

> The sleep event of the RoomClient interface fires when the room goes to sleep and the router holds the connection.

The **`sleep`** event of the [`RoomClient`](/docs/client/room-client) interface fires when the room goes to sleep: it hibernates while the router holds this client's connection.

## Syntax

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

## Event type

A plain `Event`, with no properties of its own.

## Description

When `sleep` fires, [`asleep`](/docs/client/room-client/asleep) is `true`. The connection stays open, and nobody leaves the room.

While the room sleeps:

- Messages, calls and writes the client sends wake the room and reach it once it has woken. Calls made meanwhile are answered, not failed.
- Unreliable messages and inputs are dropped.
- The client pings every 15 seconds instead of every 2. The router answers without the room's tick, so the answers don't change [`serverTick()`](/docs/client/room-client/servertick) or [`rtt`](/docs/client/room-client/rtt).

The room wakes when anything wakes it, such as another player's move or its alarm, and the client fires a [`wake` event](/docs/client/room-client/wake-event). If the connection drops while the room sleeps, `asleep` is `false` again and the client reconnects as after any drop.

## Examples

### Pausing a clock while the room sleeps

A chess client stops animating its move clock while the room sleeps, since nothing in the room counts time then.

```ts
// chess-clock.ts
import { connect } from "@irtio/client";

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

room.addEventListener("sleep", () => {
  clock.classList.add("paused");
});
room.addEventListener("wake", () => {
  clock.classList.remove("paused");
});
```

## See also

- [`RoomClient.asleep`](/docs/client/room-client/asleep)
- [`wake` event](/docs/client/room-client/wake-event)
- [`Room.hibernate()`](/docs/room/room/hibernate), the room side
- [Sleeping rooms](/docs/room/guides/hibernation#sleeping-rooms), for when a room sleeps
