# WebSocket Room

*noun*

say it: **“WEB-sah-kit ROOM”** **/ˈwɛbˌsɑkɪt rum/**

A named group of live connections that receive the same messages, such as everyone following one game.

## What is a **room** for WebSockets?

A **room** is a named group of WebSocket clients that get the same messages, such as everyone following one game. The server keeps a list of connections for each room and sends a room's messages to that list only.

```javascript
const rooms = new Map(); // "game-42" -> a Set of sockets

function sendToRoom(room, message) {
  for (const socket of rooms.get(room) ?? []) socket.send(message);
}
sendToRoom("game-42", "Goal for the home team!");
```

## In a sentence

- “Fans of game 42 join the game-42 **WebSocket room**, so they don't get scores from other games.”
- “Closing the page takes the connection out of its **WebSocket room**.”

Level: Journeyman · [More Web Development terms at this level](https://www.ask-codey.com/glossary?category=web-development&level=3)

Updated: November 19, 2026

Source: https://www.ask-codey.com/glossary/websocket-room
