Rooms are server-side groupings
A "room" is just an arbitrary string the server uses to group connections. Send to that string; everyone subscribed to it receives. The browser does not know rooms exist — the server is the gatekeeper.
Switching rooms cleanly
Letting a user move between rooms within one connection is a powerful UX (Slack, Discord). The server pattern is: receive a switch_room message → disconnect from the manager (preserves the WebSocket itself) → connect again with the new room. The same physical connection, two logical memberships.
Channels vs. rooms
Some libraries distinguish "rooms" (loose groupings) from "channels" (named, often persistent broadcast topics). The implementation is identical; the distinction is conceptual. Pick one term and stay consistent in your codebase.