pub struct ServerHandle { /* private fields */ }Expand description
Handle that can be cloned into request and event handlers for server push operations.
Carries a clone of the FrameCodec so that push operations can pre-encode
frames once and avoid per-recipient work in the writer task.
Implementations§
Source§impl ServerHandle
impl ServerHandle
Sourcepub async fn broadcast_event(
&self,
name: impl Into<String>,
data: Map<String, Value>,
attachments: Vec<FileAttachment>,
) -> Result<(), ApiError>
pub async fn broadcast_event( &self, name: impl Into<String>, data: Map<String, Value>, attachments: Vec<FileAttachment>, ) -> Result<(), ApiError>
Broadcasts an event to every live connection.
The frame is encoded exactly once and shared as Bytes across all
recipients, so the cost no longer scales with the connection count times
the payload size. A full outbound queue for a single connection drops
that one delivery instead of failing the whole broadcast.
Sourcepub async fn send_event_to(
&self,
connection_id: &str,
name: impl Into<String>,
data: Map<String, Value>,
attachments: Vec<FileAttachment>,
) -> Result<(), ApiError>
pub async fn send_event_to( &self, connection_id: &str, name: impl Into<String>, data: Map<String, Value>, attachments: Vec<FileAttachment>, ) -> Result<(), ApiError>
Sends an event to a single connection by id.
The frame is pre-encoded once so the writer task only ships bytes.
Sourcepub async fn connection_count(&self) -> usize
pub async fn connection_count(&self) -> usize
Returns the current number of live connections.
Trait Implementations§
Source§impl Clone for ServerHandle
impl Clone for ServerHandle
Source§fn clone(&self) -> ServerHandle
fn clone(&self) -> ServerHandle
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ServerHandle
impl !UnwindSafe for ServerHandle
impl Freeze for ServerHandle
impl Send for ServerHandle
impl Sync for ServerHandle
impl Unpin for ServerHandle
impl UnsafeUnpin for ServerHandle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more