await call.sendCustomEvent({
type: "draw",
x: 10,
y: 30,
});Custom Events
Send custom data between participants in real-time (e.g., synchronizing a drawing board).
Best Practices
- Keep payload under 5KB size limit.
- Always unsubscribe from events when components unmount.
- Use descriptive
typevalues to distinguish different event kinds. - Validate event data before processing to handle unexpected formats.
Sending custom events
Payload limited to 5KB.
Receiving custom events
Requires watching the call. Subscribe to custom events:
const unsubscribe = call.on("custom", (event: CustomVideoEvent) => {
const payload = event.custom;
if (payload.type === "draw") {
console.log(`Received draw event: x=${payload.x}, y=${payload.y}`);
}
});
// Unsubscribe when you no longer need to listen to custom events
unsubscribe();See Events guide for more details.