The RCWeb Chat App (app/chat) is a real-time, peer-to-peer communication application within the RCWeb ecosystem. It demonstrates the Symmetric Pattern, where multiple users running the same application in the same virtual room collaborate, share state, and exchange messages seamlessly.


The Chat app logic resides in script.js and orchestrates complex peer-to-peer messaging using the comms.js foundation.
init()), the app retrieves a saved name or generates a funny random one (e.g., "Disco Ninja"). It establishes identity (knownClients) and connects to the shared room using rc.connect().sendTextMessage() broadcasts to peers using remote function execution (rc.sendFunctionCall("chat", "chat.receiveMessage", ...)), invoking the receiveMessage() method natively on remote clients.chat.requestRefresh() asks peers for history. The sendHistory() method reconstructs remote function calls containing the message database and sends this batch payload back to the new participant to catch them up.shareImage(), an uploaded image is dynamically scaled down to max 1024x1024 on a canvas.chat.receiveMessage to recipients with a chunk proxy URL (/x-file/...). When the recipient tries to load the image, sendFileChunk() slices the Blob on the sender side and uses HTTP PUT requests to stream data fragments securely to the requester.app/v) currently active in the room via raw JavaScript execution.broadcastTyping() intelligently throttles typing status updates. When a user presses a key, it broadcasts a "true" typing state and sets a timeout. It reverts the state to "false" if the typing stops, updating the remote typingIndicator widget.