⚠️ Internal package. This is a building block of
rtcforge. Unless you need advanced/custom wiring, installrtcforgeand import fromrtcforge/client,rtcforge/server,rtcforge/media, orrtcforge/filetransferinstead.
Browser + Node.js client for RTCForge — connect, join rooms, exchange signaling.
The client your app code talks to. RTCForgeClient connects to a rtcforge-signaling server, joins a Room, and handles reconnect, a send queue for offline messages, and a pluggable Transport.
A signaling server is useless without a client that speaks its protocol. The SDK hides the WebSocket details — connection state, reconnection with backoff, message queuing — behind a small API, and runs identically in the browser and Node.
your app → rtcforge-sdk ⇄ rtcforge-signaling
└─ feed Room into rtcforge-media for audio/video
Client layer.
RTCForgeClient — connection + room lifecycle, reconnect strategy, send queue.Room — peers and signaling events for one session.WebSocketTransport (default) / Transport interface — swap the wire (e.g. for tests).// createClient defaults reconnect on + a warn console logger; or use `new RTCForgeClient(...)`.
import { createClient } from "rtcforge-sdk";
const client = createClient({ serverUrl: "wss://your-signaling-host" });
const room = await client.joinRoom("my-room"); // connects + joins
// client.room reaches the joined room without holding the return value.
// PeerJoined/PeerLeft payloads are the peer id (a string), not an object:
room.on("peer-joined", (peerId) => console.log("joined:", peerId));
// Exchange application messages over the room. A single "broadcast" event
// carries (from, channel, data) — filter by channel yourself:
room.broadcast("chat", { text: "hello" });
room.on("broadcast", (from, channel, data) => {
if (channel === "chat") console.log(from, data.text);
});
For audio/video, pass the Room to rtcforge-media.
Part of RTCForge. See docs/PUBLISHING.md.