Skip to content
All guides

learn

Stream

Stream is live framed messages. That is the WebSocket job. The name is Buraaq's.

Not a browser API. Not a Node event emitter. A port, a wire, text frames, plus audio clips and video shots.

Listen

fn main() {
    stream(9420)
    run_stream()
}

stream(port) binds. run_stream() accepts forever and echoes text, clips, and shots. hail() accepts one client when you want the loop yourself.

Connect

fn main() {
    s = wire("ws://127.0.0.1:9420/")
    say(s, "hello")
    clip(s, "step.wav")
    shot(s, "frame.png")
    msg = hear(s)
    kind = heard()
    hangup(s)
}

hear of a text frame is the message. hear of a clip or shot is a temp path on disk. heard() is "text", "clip", "shot", or empty.

APIWhat it does
stream(port)Bind
run_stream()Accept forever and echo
hail()Accept one client
wire(url)Connect ws://host:port/path
say / hear / hangupText frames; binary hear returns a path
clip(id, path)Send an audio file
shot(id, path)Send a video or image file
heard()Kind of the last hear

Project compile auto-imports unique names. You do not stay in use ceremony.

A/V without a live peer: stdlib/examples/stream_av.bq (heard, then clip / shot on a dead id). Echo server: stdlib/examples/stream.bq.

Pixels and local sound are Gfx. Next: Hold.