TypeScript SDK
Install
Section titled “Install”During developer preview, install directly from GitHub:
npm install github:Tomo-Social/tomo-streaming-sdkCreate from your backend
Section titled “Create from your backend”import { TomoStreamingClient } from "@tomo/streaming-sdk";
const tomo = new TomoStreamingClient({ baseUrl: "https://stream.example.com", apiKey: process.env.TOMO_STREAM_API_KEY!,});
const session = await tomo.createSession({ type: "desktop-stream-server", name: "Shared workspace", config: { display: ":0", width: 1280, height: 720, fps: 30 },});Available methods
Section titled “Available methods”| Method | Purpose |
|---|---|
listSessions() |
List sessions owned by the current API key |
createSession(input) |
Start a camera, desktop or plugin session |
getSession(id) |
Read current lifecycle and activity state |
action(id, action) |
pause, resume or restart a session |
deleteSession(id) |
Stop and remove its runtime |
signalingUrl(session) |
Build the matching secure WebSocket URL |
joinMessage(session, username?) |
Build the player join envelope |
Join signaling
Section titled “Join signaling”const socket = new WebSocket(tomo.signalingUrl(session));
socket.addEventListener("open", () => { socket.send(JSON.stringify(tomo.joinMessage(session, "viewer-1")));});Media and input travel through WebRTC, not through the REST client.
Interactive input
Section titled “Interactive input”import { TomoStreamInput } from "@tomo/streaming-sdk";
inputChannel.send(TomoStreamInput.keyboard(0x04, true));inputChannel.send(TomoStreamInput.pointer(32_768, 32_768, 0));inputChannel.send(TomoStreamInput.wheel(0, -120));Each helper returns ArrayBuffer, so it can be passed directly to RTCDataChannel.send without the modern TypeScript Uint8Array<ArrayBufferLike> overload mismatch.