Realtime
clepit has two realtime surfaces: the Socket.IO /content namespace for document changes, and a raw WebSocket for collaborative editing.
| Surface | Address | Carries |
|---|---|---|
| Socket.IO | wss://ws.clepit.com/content | pageChanged and other document events |
| Raw WebSocket | wss://ws.clepit.com/collab/pages/{pageId} | Collaborative editing (CRDT updates) |
Document events
A connection is authenticated at handshake and joined to the rooms its tenant owns. Fan-out is filtered per subscriber: a socket only receives an event for a page it is permitted to see, checked at emit time rather than at subscribe time.
TypeScript
import { io } from 'socket.io-client';
const socket = io('https://ws.clepit.com/content', {
auth: { token: accessToken },
});
socket.on('pageChanged', ({ pageId, data }) => {
// data is the serialised change for pageId
});Collaborative editing
The collab socket is a separate, binary channel carrying CRDT updates for one page. It is not Socket.IO, it is a raw WebSocket, because the payload is binary and the protocol is the CRDT’s own.
TypeScript
const socket = new WebSocket(
`wss://ws.clepit.com/collab/pages/${pageId}?token=${accessToken}`,
);
socket.binaryType = 'arraybuffer';
socket.onmessage = event => applyUpdate(doc, new Uint8Array(event.data));