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: Value,
attachments: Vec<FileAttachment>,
) -> Result<(), ApiError>
pub async fn broadcast_event( &self, name: impl Into<String>, data: 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 broadcast_persisted_event(
&self,
name: impl Into<String>,
data: Value,
attachments: Vec<FileAttachment>,
storage_id: u64,
) -> Result<(), ApiError>
pub async fn broadcast_persisted_event( &self, name: impl Into<String>, data: Value, attachments: Vec<FileAttachment>, storage_id: u64, ) -> Result<(), ApiError>
Broadcasts a persisted event to every live connection, carrying a
storage id (si field) assigned by a database or other persistent store.
Sourcepub async fn send_event_to(
&self,
connection_id: &str,
name: impl Into<String>,
data: Value,
attachments: Vec<FileAttachment>,
) -> Result<(), ApiError>
pub async fn send_event_to( &self, connection_id: &str, name: impl Into<String>, data: 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 send_persisted_event_to(
&self,
connection_id: &str,
name: impl Into<String>,
data: Value,
attachments: Vec<FileAttachment>,
storage_id: u64,
) -> Result<(), ApiError>
pub async fn send_persisted_event_to( &self, connection_id: &str, name: impl Into<String>, data: Value, attachments: Vec<FileAttachment>, storage_id: u64, ) -> Result<(), ApiError>
Sends a persisted event to a single connection by id, carrying a
storage id (si field) assigned by a database or other persistent store.
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
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more