pub struct ServerHandle { /* private fields */ }Expand description
Cloneable command and management endpoint for a running Server.
The handle does not drive I/O itself: Server::run must remain active.
Clones share call-ID allocation, retained media statistics, and the bounded
command queue. Dropping the last handle closes that queue and lets the run
loop perform its normal session shutdown.
Implementations§
Source§impl ServerHandle
impl ServerHandle
Sourcepub fn set_call_answer_order(&self, order: CallSelectionOrder)
pub fn set_call_answer_order(&self, order: CallSelectionOrder)
Applies to future answer requests that omit their call reference. Explicit references and existing session calls are not rewritten.
Sourcepub fn latest_media_statistics(
&self,
device_id: &DeviceId,
) -> Option<MediaStatisticsSnapshot>
pub fn latest_media_statistics( &self, device_id: &DeviceId, ) -> Option<MediaStatisticsSnapshot>
Return the latest fully correlated statistics response for a device.
Snapshots survive call and session teardown until a newer response for that device replaces them or the server is dropped.
Sourcepub fn media_statistics(&self) -> Vec<(DeviceId, MediaStatisticsSnapshot)>
pub fn media_statistics(&self) -> Vec<(DeviceId, MediaStatisticsSnapshot)>
Clone every retained per-device snapshot, releasing the internal lock before a caller sorts, filters, or formats management output.
Sourcepub async fn send(&self, command: Command) -> Result<(), ServerError>
pub async fn send(&self, command: Command) -> Result<(), ServerError>
Enqueue a station command, waiting for capacity in the server queue.
Success confirms queue admission only. The command may subsequently be
discarded if the target session retired, and any station response is
reported separately through Event. Use Self::send_confirmed when
adapter resource lifetime depends on completion of the stream write.
Sourcepub async fn send_confirmed(&self, command: Command) -> Result<(), ServerError>
pub async fn send_confirmed(&self, command: Command) -> Result<(), ServerError>
Send a command and wait until its complete encoded frame has been written to the registered device’s TCP stream.
This is intentionally stronger than Self::send, whose completion
only means the command entered the server queue. Lifecycle-sensitive
callers use this boundary before releasing resources that protect the
command’s on-device operation.
Sourcepub fn try_send(&self, command: Command) -> Result<(), ServerError>
pub fn try_send(&self, command: Command) -> Result<(), ServerError>
Enqueue a command without yielding, preserving the ordering of synchronous channel-driver callbacks such as call followed by hangup.
Sourcepub async fn offer_incoming_call(
&self,
device_id: DeviceId,
line_instance: LineInstance,
info: CallInfo,
) -> Result<CallId, ServerError>
pub async fn offer_incoming_call( &self, device_id: DeviceId, line_instance: LineInstance, info: CallInfo, ) -> Result<CallId, ServerError>
Allocate a call ID and enqueue an ordinarily ringing incoming offer.
The returned identity is stable across all later commands and handset events for the offer. A failed enqueue still consumes the reserved ID.
Sourcepub fn reserve_call_id(&self) -> CallId
pub fn reserve_call_id(&self) -> CallId
Reserve a call ID before exposing a call to a protocol session.
Channel-driver adapters use this to install all private channel state before the handset can answer the subsequent offer.
Sourcepub async fn offer_incoming_call_with_id(
&self,
device_id: DeviceId,
line_instance: LineInstance,
call_id: CallId,
info: CallInfo,
) -> Result<(), ServerError>
pub async fn offer_incoming_call_with_id( &self, device_id: DeviceId, line_instance: LineInstance, call_id: CallId, info: CallInfo, ) -> Result<(), ServerError>
Offer an incoming call using an ID previously returned by
Self::reserve_call_id.
pub async fn offer_incoming_call_with_id_and_ring( &self, device_id: DeviceId, line_instance: LineInstance, call_id: CallId, info: CallInfo, audible_ring: bool, ) -> Result<(), ServerError>
Sourcepub async fn offer_incoming_call_with_id_and_ringer(
&self,
device_id: DeviceId,
line_instance: LineInstance,
call_id: CallId,
info: CallInfo,
presentation: IncomingPresentation,
ringer: Option<IncomingRing>,
) -> Result<(), ServerError>
pub async fn offer_incoming_call_with_id_and_ringer( &self, device_id: DeviceId, line_instance: LineInstance, call_id: CallId, info: CallInfo, presentation: IncomingPresentation, ringer: Option<IncomingRing>, ) -> Result<(), ServerError>
Enqueue an incoming offer with explicit audible presentation.
None creates a silent offer. Some applies the supplied ring mode and
duration before selecting the incoming-call soft-key state.
Sourcepub fn try_offer_incoming_call_with_id(
&self,
device_id: DeviceId,
line_instance: LineInstance,
call_id: CallId,
info: CallInfo,
) -> Result<(), ServerError>
pub fn try_offer_incoming_call_with_id( &self, device_id: DeviceId, line_instance: LineInstance, call_id: CallId, info: CallInfo, ) -> Result<(), ServerError>
Enqueue an incoming offer without yielding. Channel drivers should use this from their synchronous call callback so a following hangup cannot overtake the offer.
Sourcepub fn try_offer_incoming_call_with_id_and_ring(
&self,
device_id: DeviceId,
line_instance: LineInstance,
call_id: CallId,
info: CallInfo,
audible_ring: bool,
) -> Result<(), ServerError>
pub fn try_offer_incoming_call_with_id_and_ring( &self, device_id: DeviceId, line_instance: LineInstance, call_id: CallId, info: CallInfo, audible_ring: bool, ) -> Result<(), ServerError>
Non-blocking form of Self::offer_incoming_call_with_id_and_ring.
Returns ServerError::CommandQueueFull without changing session state
when immediate queue capacity is unavailable.
pub fn try_offer_incoming_call_with_id_and_ringer( &self, device_id: DeviceId, line_instance: LineInstance, call_id: CallId, info: CallInfo, presentation: IncomingPresentation, ringer: Option<IncomingRing>, ) -> Result<(), ServerError>
pub async fn offer_incoming_call_for_session( &self, target: StationSessionTarget, line_instance: LineInstance, call_id: CallId, info: CallInfo, presentation: IncomingPresentation, ringer: Option<IncomingRing>, ) -> Result<IncomingOfferReceipt, ServerError>
pub fn try_offer_incoming_call_for_session( &self, target: StationSessionTarget, line_instance: LineInstance, call_id: CallId, info: CallInfo, presentation: IncomingPresentation, ringer: Option<IncomingRing>, ) -> Result<IncomingOfferReceipt, ServerError>
Sourcepub async fn shutdown(&self) -> Result<(), ServerError>
pub async fn shutdown(&self) -> Result<(), ServerError>
Request orderly server shutdown.
Success means the request entered the queue. The owner must still await
the Server::run future to know that it stopped accepting streams and
issued disconnects to every registered session.
Sourcepub async fn reconfigure(
&self,
definitions: impl IntoIterator<Item = DeviceDefinition>,
) -> Result<ReconfigureResult, ServerError>
pub async fn reconfigure( &self, definitions: impl IntoIterator<Item = DeviceDefinition>, ) -> Result<ReconfigureResult, ServerError>
Atomically replace the configured station definitions. Only connected stations whose definition changed or was removed are asked to register again; unchanged live sessions and calls are preserved. Success means the replacement was committed and disconnect requests were queued, not that every affected transport has already closed.
Sourcepub async fn reconfigure_affected(
&self,
definitions: impl IntoIterator<Item = DeviceDefinition>,
affected: impl IntoIterator<Item = DeviceId>,
) -> Result<ReconfigureResult, ServerError>
pub async fn reconfigure_affected( &self, definitions: impl IntoIterator<Item = DeviceDefinition>, affected: impl IntoIterator<Item = DeviceId>, ) -> Result<ReconfigureResult, ServerError>
Atomically replaces station definitions and reconnects the explicit
set in addition to stations whose wire definition changed. This lets a
higher-level configuration owner apply line or global policy changes
whose effects are not represented in DeviceDefinition.
Sourcepub async fn reconfigure_station_policy(
&self,
definitions: impl IntoIterator<Item = DeviceDefinition>,
affected: impl IntoIterator<Item = DeviceId>,
anonymous_hotline: Option<AnonymousHotlineDefinition>,
) -> Result<ReconfigureResult, ServerError>
pub async fn reconfigure_station_policy( &self, definitions: impl IntoIterator<Item = DeviceDefinition>, affected: impl IntoIterator<Item = DeviceId>, anonymous_hotline: Option<AnonymousHotlineDefinition>, ) -> Result<ReconfigureResult, ServerError>
Commits station definitions and unknown-device admission as one server transaction before any affected session is disconnected.
Sourcepub async fn reconfigure_anonymous_hotline(
&self,
definition: Option<AnonymousHotlineDefinition>,
) -> Result<usize, ServerError>
pub async fn reconfigure_anonymous_hotline( &self, definition: Option<AnonymousHotlineDefinition>, ) -> Result<usize, ServerError>
Replace the unknown-device guest template for future registrations. A changed policy disconnects only sessions that were admitted through the previous anonymous template; configured sessions are untouched. The returned count is the number of such sessions asked to disconnect.
Trait Implementations§
Source§impl Clone for ServerHandle
impl Clone for ServerHandle
Source§fn clone(&self) -> ServerHandle
fn clone(&self) -> ServerHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more