reactor.on(event, handler). Both
approaches are equivalent. Use whichever you prefer.
Receiving video frames
Register on theTrack itself, found by name or by
filtering reactor.tracks:
Example
Use
on_raw_frame() instead of on_frame() for the
same frames as raw bytes, with no NumPy conversion; see Track for
the full API.@reactor.on_message
Registers a handler for messages from the model.
Signature
message is the payload sent by the model (typically a dictionary). Shape depends on the model.
Example
@reactor.on_status
Registers a handler for connection status changes. Supports three usage patterns.
Signature
Example
@reactor.on_error
Registers a handler for errors.
Signature
error is a ReactorError with fields code,
message, timestamp_ms, recoverable, and optional status, operation, retry_after_ms.
Example
@reactor.on_track
Registers a handler for recvonly tracks becoming available. Unlike the other decorators here, it
does not filter by name — check track.name yourself if you only care about one track.
Signature
track is the Track itself — reactor.track(track.name),
already resolved — not a bare name to look up before doing anything with it. Its .mid is the
WebRTC media stream ID, or None if it has not been negotiated yet.
Example
This does not hand over decoded media — there is no
MediaStreamTrack in this SDK, and the
Track it hands over is a control handle (name, kind, direction, push_frame/on_frame,
publish/pause/resume), not a frame source by itself. This event is for knowing when a named
track becomes available at all (e.g. to enable a UI element for it); to register a handler that
only fires for one track’s decoded frames, use
track.on_frame instead.