Examples menu

๐Ÿ’ฌ Chat Room

Chat: Random

Custom scopes isolate each room. Messages in "lobby" never leak to "general" โ€” each room has its own broadcast channel built with Scope::build().
Session-scoped usernames persist across tabs. Your username is stored in SESSION scope, so switching rooms or opening a new tab keeps the same identity.
Presence + typing indicators update in real time. When a user disconnects, the onDisconnect hook removes them from the room's user list.
addScope() lets a context join a broadcast channel mid-flight. The room page starts in TAB scope for private input, then adds the room scope for shared messages.
In-memory message store keeps this demo self-contained. Messages persist as long as the server runs โ€” no database required for a working chat.
Multi-room architecture โ€” open two rooms side by side. Each room's scope is independent, so typing in Lobby has no effect on General.
Random
UserD323 UserB5CF (you)
UserEC24 09:06:27
hello

โšก Signals

username string SESSION

Persists across tabs. Same identity whether you switch rooms or open new tabs.

messageInput string TAB ""

Current message draft. Private to this tab.

typingIndicator string Custom

Custom room scope. Shows "User is typing..." to everyone in the same room.

๐ŸŽฏ Actions

sendMessage

Appends message to the room, clears input, resets typing indicator, and broadcasts to room.

updateTyping

Sets the typing indicator with username and broadcasts to room.

๐Ÿ‘ Views

chat_room.html.twig

Sidebar room list + chat panel with message list, user presence, and typing indicator. Uses onDisconnect for cleanup.