Beta status: Supported. The
CallbackPeerreactive surface is supported. SeeCOMPATIBILITY_MATRIX.md.
Where StreamPeer is sequential (you call it), CallbackPeer is reactive
(it calls you): you register hooks and the library dispatches typed events into
them. That's the right model for servers — IVRs, routing front-ends, auto-answer
endpoints. This demo wires the builder form with on_incoming, on_established,
on_dtmf, and on_ended, and a scripted caller exercises it.
- server (the IVR,
:5120) accepts inbound calls and reacts to DTMF. Press0and it would blind-transfer you to an operator. - caller (
:5121) connects and sends1,2,#. - The IVR logs each press; the caller hangs up.
caller (:5121) ── INVITE ─▶ IVR server (:5120)
│ ◀──────── 200 OK ─────── on_incoming → Accept
│ ── DTMF 1, 2, # ────────▶ on_dtmf hook fires per digit
│ ── BYE ─────────────────▶ on_ended
./run_demo.shOr manually:
cargo run --bin server
cargo run --bin caller [ivr] listening on sip:ivr@127.0.0.1:5120
[ivr] incoming call from …
[ivr] ✅ call … established
[ivr] call … pressed 1
[caller] ✅ connected to IVR
[caller] sent DTMF 1
✅ DEMO SUCCESSFUL — IVR reacted to inbound call + DTMF
- The example uses the builder closures. For complex servers, implement the
CallHandlertrait (see the in-cratecallback_peer/06_trait_handler), or use the built-inRoutingHandler/QueueHandler. - Pressing
0triggerstransfer_blindto an operator URI that isn't started in this two-process demo, so the caller only sends1,2,#.
- Caller can't connect — start the server first;
run_demo.shwaits for the IVR's port.
- 10-call-center-b2bua — route + bridge across legs.
- In-crate references:
callback_peer/(six numbered handler scenarios).