This document explains how the Drums application leverages RCWeb technology to enable a real-time, collaborative drum machine experience across multiple devices.
The Drums app uses a symmetric peer-to-peer model similar to the Chat application. All clients join the same room and synchronize their state (the drum grid, BPM, and playback status) directly with each other.
drums.setBeatNetwork(...) call to all other peers.
rc.sendFunctionCall to
invoke remote functions. This ensures that arguments (like the drum grid object or BPM integer) are
properly serialized and escaped before being executed by other clients.drums.remotePlay command with a calculated wait time for each
client, ensuring everyone hears the beat at exactly the same time.Load comms.js before the app script. Room and client values are available after
rc.onConnected fires.
<script src="/assets/core/comms.js"></script>
<script src="script.js"></script>
rc.sendFunctionCallTo synchronize actions, the app defines global functions that are invoked remotely:
// Broadcasting a beat toggle
rc.sendFunctionCall("drums", "drums.setBeatNetwork", row, col, newState);
// Synchronizing the entire grid (e.g. on preset load)
rc.sendFunctionCall("drums", "drums.setGridNetwork", newGrid);
The app performs a quick "ping-pong" handshake to measure network delay before starting playback:
drums.receivePing.drums.receivePong.drums.remotePlay with relative wait
times.The Drums example demonstrates how RCWeb can be used for more than just simple data transfer—it enables complex, time-sensitive collaborative applications by treating remote browser instances as part of a distributed execution environment.