Last updated 2026-07-12
This guide walks through building an interactive live streaming app — a host broadcasts video, viewers watch in real time. We use WebSocket and WebRTC, the same stack openbnet Live Streaming is built on.
An interactive live streaming app: a host creates a stream channel, starts broadcasting camera/screen, and viewers join the channel to watch in real time. Unlike video calling, streaming is one-to-many — the host sends, viewers receive. openbnet supports multi-host streaming via a bridge-tunnel architecture.
Connect to the openbnet WebSocket and create a stream channel. This sets up the broadcast room that viewers will join.
const ws = new WebSocket(
`wss://openbnet.com/ss/ws?user_id=${userId}&email=${email}`
);
ws.onopen = () => {
ws.send(JSON.stringify({
type: 'create-stream-channel',
payload: {
channel_id: 'my-channel',
title: 'Live Stream',
description: 'Building in public'
}
}));
};
Capture the host's camera and/or screen, then signal the server to start streaming. The server begins distributing the host media to connected viewers.
const stream = await navigator.mediaDevices.getUserMedia({
video: true, audio: true
});
// Or screen share:
// const stream = await navigator.mediaDevices.getDisplayMedia();
ws.send(JSON.stringify({
type: 'start-streaming',
payload: { channel_id: 'my-channel' }
}));
Viewers connect to the same WebSocket and join the stream channel. The server sends them the host's media stream.
// Viewer code
const ws = new WebSocket(
`wss://openbnet.com/ss/ws?user_id=${viewerId}`
);
ws.onopen = () => {
ws.send(JSON.stringify({
type: 'join-stream',
payload: { channel_id: 'my-channel', user_id: viewerId }
}));
};
openbnet supports multi-host streaming via a bridge-tunnel architecture. You can add co-hosts mid-stream, with per-bridge audio control for viewers. Each host becomes a "bridge" in the tunnel.
// Add a co-host to an existing stream
ws.send(JSON.stringify({
type: 'add-bridge',
payload: {
channel_id: 'my-channel',
bridge_user_id: coHostId,
bridge_type: 'webcam' // or 'screen', 'audio'
}
}));
// Per-bridge audio control — let a viewer mute a specific host
ws.send(JSON.stringify({
type: 'set-bridge-audio',
payload: {
channel_id: 'my-channel',
bridge_id: bridgeId,
muted: true
}
}));
Use the REST API to check live viewer counts and stream analytics. This is useful for dashboard displays and streamer feedback.
// Get viewer count
const res = await fetch(
'https://openbnet.com/api/streams/analytics?channel_id=my-channel'
);
const { viewer_count, duration, latency } = await res.json();
console.log(`${viewer_count} watching, ${latency}ms latency`);
You now have a working live streaming app with multi-host support and analytics. openbnet Live Streaming handles the bridge-tunnel architecture, viewer fan-out, and REST analytics — explore the product page for the full API.
openbnet developer hub → · Pricing →
openbnet is the real-time communication infrastructure company founded by Brian. It builds the openbnet platform — six production-ready APIs for voice, video, chat, live streaming, signaling, and AI content moderation — plus solutions on that platform: Ocodey, the CLI coding agent; Spaces, managed communities; Atrium, a platform for running a company; and Chapmall, an online mall for local shops and delivery. One openbnet account signs you in to every solution.
Website: openbnet.com · GitHub: github.com/openbnet · X: @openbnet