Examples menu

๐Ÿ’ฌ Chat Room

Chat: Lobby

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.
Lobby
User3EAD User703B UserB3EC User89D0 User33AF User4132 (you)
UserEAAB 08:45:20
hello
Unknown 10:26:49
?
UserD3A8 10:34:41
oi
Unknown 13:12:02
I iz in ur chat, typin!
UserCC2D 13:20:08
gloups
UserEAAF 14:38:53
ๆฐด็”ต่ดน
UserEAAB 15:13:00
quak
UserF936 16:42:42
Supo
User1B08 17:50:54
yo
User8052 17:52:06
hmm
User8052 17:52:32
very cool
User1B08 17:53:29
wee
UserC9E0 20:28:20
Woo
User28A4 20:45:24
yo
UserE7D2 21:45:17
poop
UserE7D2 21:45:30
This is coooooool
UserC9E0 22:57:31
Badum tss
User41C0 23:50:50
bro
User41C0 23:50:53
wtf
User41C0 23:51:07
this is awesome
User41C0 23:52:40
asd
UserEC24 09:05:57
good
User0551 14:12:42
e
User0551 14:12:52
ssss
User0551 14:13:01
rm -rf
UserEDD2 15:32:04
sfsfds

โšก 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.