Audio & Video Bridge | WebRTC
NEW VIDEO BRIDGE and NEW AUDIO BRIDGE allocate a signaling room on Ocalt's servers for a fixed number of peers. The room object they return is overloaded: it carries ready-to-send join links with a built-in minimal call UI, a raw connection URL for wiring into your own frontend, and the room's internal id for closing it later. Ocalt's server only relays signaling — it never touches your audio or video.
Creating a Bridge
Give the number of peers the room should hold. Every peer slot is generated up front, at creation time.
NEW VIDEO BRIDGE 2 PEERS SET ?room
AFTER EMIT ?room("peers")(0)
AFTER EMIT ?room("peers")(1)
NEW AUDIO BRIDGE 2 PEERS SET ?room
AFTER EMIT ?room("peers")(0)
AFTER EMIT ?room("peers")(1)
VIDEO and AUDIO bridges use an identical signaling layer — the only difference is what a peer's frontend requests from getUserMedia(): video and audio together, or audio alone. The built-in UI (see below) handles this for you automatically based on which verb created the room.
The Room Object
The variable you SET the room into — ?room here, but the name is yours — is an overloaded object with three faces. Use whichever fits how you want to build.
| Accessor | What it is |
|---|---|
?room("peers")(i) | A ready-to-send join link for peer slot i. Open it in a browser — or send it to someone — and it loads Ocalt's default minimal call interface, already wired to that slot. No code required. Nothing to build. |
?room("connection") | The raw connection URL — a plain parameter you feed into your own frontend code. Use this when you are building a custom call interface instead of using the ready-made links. |
?room("id") | The internal id/token Ocalt registers for this room. You pass it to BRIDGE CLOSE to tear the room down. |
The Easy Path — Ready-Made Join Links
Each ?room("peers")(i) is a complete, working call page hosted by Ocalt. You do not build anything — you distribute the links. Send peer 0's link to one participant and peer 1's to the other, however you like: email, SMS, a button on your site, a chat message.
NEW VIDEO BRIDGE 2 PEERS SET ?room
AFTER EMIT "Your link: " & ?room("peers")(0)
AFTER EMIT "Their link: " & ?room("peers")(1)
(* Each link opens Ocalt's built-in call UI, already bound to that peer slot.
Whoever opens peer 0's link is peer 0; whoever opens peer 1's link is peer 1. *)
n PEERS creates n join links and lets up to n people be in the room at once. The links are equivalent entry points — identity is assigned as each person actually connects, in the order they arrive, not fixed to a particular link ahead of time. Hand out one link per participant; when the room is full, further connections are refused until someone leaves. If every peer disconnects, the room is torn down after a short grace period.The Custom Path — Your Own Frontend
If you want your own interface instead of the built-in UI, take ?room("connection") and open it from your own JavaScript. It is the same underlying signaling channel the ready-made links use — you are simply supplying your own page around it.
NEW VIDEO BRIDGE 2 PEERS SET ?room
AFTER EMIT NEW HTML
OPEN
EMIT "<video id='local' autoplay muted playsinline></video>"
AFTER EMIT "<video id='remote' autoplay playsinline></video>"
AFTER EMIT "<script>const CONNECTION = '" & ?room("connection") & "';</script>"
AFTER EMIT "<script src='/your-call-code.js'></script>"
CLOSE
Closing a Bridge
A room runs independently of the script that created it. Close it explicitly with a later call, passing the room's id. BRIDGE CLOSE takes any expression that evaluates to that id — a variable, an object field, or a session value.
BRIDGE CLOSE ?room("id")
SET "myroom" AS ?room OF !SESSION
(* ...later request... *)
AFTER SET ?room AS !SESSION("myroom")
AFTER BRIDGE CLOSE ?room("id")
Or just keep the id and close directly against it — no need to reconstruct the object:
SET "myroomid" AS ?room("id") OF !SESSION
(* ...later request... *)
AFTER BRIDGE CLOSE !SESSION("myroomid")
Any of these work: BRIDGE CLOSE ?room("id"), BRIDGE CLOSE ?myid, BRIDGE CLOSE !SESSION("myroomid") — the verb only cares about the id value it receives.What Ocalt's Signaling Server Does
The connection channel carries each peer's room token. Ocalt's server matches peers into the same room and relays SDP offers/answers and ICE candidates between them until their browsers establish a direct (or TURN-relayed) peer-to-peer connection. Once connected, audio and video flow directly between the browsers — never through Ocalt's servers.
Full Verb Reference
| Verb | Description |
|---|---|
NEW VIDEO BRIDGE n PEERS SET ?room | Allocate a video signaling room for n peers |
NEW AUDIO BRIDGE n PEERS SET ?room | Allocate an audio-only signaling room for n peers |
?room("peers")(i) | Ready-to-send join link with a built-in minimal UI, bound to peer slot i |
?room("connection") | Raw connection URL parameter for wiring into your own frontend |
?room("id") | The room's internal id/token, used to close it |
BRIDGE CLOSE ?room("id") | Explicitly close a room and its signaling state (id may be any expression) |