pub struct ProcessClient { /* private fields */ }Expand description
Handle to one agent worker process. Spawn it with ProcessClient::spawn,
then drive it: fire-and-forget call-control commands, blocking queries (media
stats, received DTMF, tone analysis, …), and an AppEvent stream (returned
by spawn). Dropping it deregisters and reaps the worker.
Implementations§
Source§impl ProcessClient
impl ProcessClient
Sourcepub fn spawn(config: AgentConfig) -> Result<(Self, Receiver<AppEvent>)>
pub fn spawn(config: AgentConfig) -> Result<(Self, Receiver<AppEvent>)>
Spawn a worker for config, returning the client and the agent’s event
stream (already converted to backend-neutral AppEvents).
Sourcepub fn pid(&self) -> u32
pub fn pid(&self) -> u32
The worker’s OS process id — the <pid> in its per-agent log and SIP
trace file names (see crate::worker::per_agent_path).
Sourcepub fn headers_handle(&self) -> Arc<Mutex<Option<InviteHeaders>>> ⓘ
pub fn headers_handle(&self) -> Arc<Mutex<Option<InviteHeaders>>> ⓘ
A clone of the inbound-header buffer, for building a header_poll closure.
Sourcepub fn request_shutdown(&self)
pub fn request_shutdown(&self)
Tell the worker to shut down (deregister + exit) without blocking. Sent at most once; call this on all agents before dropping them so their de-REGISTERs run concurrently instead of one-at-a-time on each drop.
Sourcepub fn register(&self, aor: &str, regint: u32)
pub fn register(&self, aor: &str, regint: u32)
Register the account at aor with the given re-register interval (s).
Sourcepub fn dial(&self, number: &str)
pub fn dial(&self, number: &str)
Place an outgoing call to number (a SIP URI or a bare number/extension).
Sourcepub fn hangup_all(&self)
pub fn hangup_all(&self)
Hang up all calls.
Sourcepub fn switch_line(&self, line: usize)
pub fn switch_line(&self, line: usize)
Not yet exposed by a scenario verb (line switching is planned).
Sourcepub fn attended_transfer_start(&self, uri: &str)
pub fn attended_transfer_start(&self, uri: &str)
Start an attended transfer: call uri as a consultation call.
Sourcepub fn attended_transfer_exec(&self)
pub fn attended_transfer_exec(&self)
Complete the attended transfer (connect the two parties).
Sourcepub fn attended_transfer_abort(&self)
pub fn attended_transfer_abort(&self)
Abort the attended transfer (hang up the consultation call).
Sourcepub fn add_header(&self, key: &str, value: &str)
pub fn add_header(&self, key: &str, value: &str)
Add a custom SIP header sent on subsequent requests.
Sourcepub fn rm_header(&self, key: &str)
pub fn rm_header(&self, key: &str)
Remove ALL custom headers with this name (the worker’s uarmheader
semantics). Used by ringo-mcp for replace-on-add and by the phone’s
per-call header re-rendering.
Sourcepub fn set_audio_source(&self, spec: &str)
pub fn set_audio_source(&self, spec: &str)
Switch the active call’s audio source (e.g. a tone, a file, or silence).
Sourcepub fn set_recording(&self, on: bool)
pub fn set_recording(&self, on: bool)
Arm or disarm full-call recording for the agent’s UA: arming starts a fresh recording (a previous one is cleared); disarming keeps what was recorded until the next arm/call. Fire-and-forget like the worker’s other recording-free commands.
Sourcepub fn arm_invite_response(
&self,
scode: u16,
reason: &str,
headers: Vec<String>,
)
pub fn arm_invite_response( &self, scode: u16, reason: &str, headers: Vec<String>, )
Arm a fixed response (status scode/reason + extra headers) for the
next inbound INVITE instead of accepting it.
Sourcepub fn disarm_invite_response(&self)
pub fn disarm_invite_response(&self)
Clear a previously armed invite response (accept incoming calls again).
Sourcepub fn deflect_incoming(&self, contact: &str, diversion: Option<&str>)
pub fn deflect_incoming(&self, contact: &str, diversion: Option<&str>)
Mirror of the Phone::deflect_incoming default: arm a 302 with Contact
(and optional RFC 5806 Diversion).
Sourcepub fn media_stats(&self) -> Option<MediaStats>
pub fn media_stats(&self) -> Option<MediaStats>
RTP media stats for the active/last call, or None if unavailable.
Sourcepub fn received_dtmf(&self) -> String
pub fn received_dtmf(&self) -> String
DTMF digits received on the active/last call so far, in order.
Sourcepub fn save_audio(&self, prefix: &str) -> Vec<String>
pub fn save_audio(&self, prefix: &str) -> Vec<String>
Ask the worker to write its captured audio to <prefix>-sent.wav /
<prefix>-recv.wav; returns the paths written.
Sourcepub fn save_audio_detailed(&self, prefix: &str) -> Vec<SavedAudio>
pub fn save_audio_detailed(&self, prefix: &str) -> Vec<SavedAudio>
Like Self::save_audio, but returns what each written WAV contains
(side, duration, whether the retention cap truncated it) — the honest
form for callers that report recordings.
Sourcepub fn call_count(&self) -> u32
pub fn call_count(&self) -> u32
Number of active calls in the worker (0 if the worker is gone).
Sourcepub fn start_tx_audio(&self, rate: u32)
pub fn start_tx_audio(&self, rate: u32)
Switch the agent’s audio source to live-streamed mono s16 PCM at rate Hz;
feed it with Self::push_tx_audio (e.g. TTS output). Call this and feed
push_tx_audio from the same thread: the worker requires the
StartTxAudio control frame to arrive before any audio frame (it drops
audio that arrives first), and the stdin lock is not FIFO across threads.
Sourcepub fn push_tx_audio(&self, samples: &[i16])
pub fn push_tx_audio(&self, samples: &[i16])
Stream mono s16 PCM into the call as a raw audio frame (after
Self::start_tx_audio, from the same thread).
Sourcepub fn start_rx_audio(&self) -> Receiver<AudioFrame>
pub fn start_rx_audio(&self) -> Receiver<AudioFrame>
Start streaming the agent’s received audio; returns a receiver of mono
AudioFrames (e.g. to feed STT or a parent-side tone analysis). One
subscription per client.