pub struct PushServer<C: ChannelKind> { /* private fields */ }Expand description
Generic multiplexed push server parameterized by channel type.
C implements ChannelKind and defines the channel taxonomy.
Channel-specific handling is registered by the consumer via
register_handler.
Implementations§
Source§impl<C: ChannelKind> PushServer<C>
impl<C: ChannelKind> PushServer<C>
pub fn new() -> Self
pub fn with_auth_validator(auth_validator: AuthValidator<C>) -> Self
Sourcepub fn router(self: Arc<Self>) -> Router<Arc<Self>>
pub fn router(self: Arc<Self>) -> Router<Arc<Self>>
Axum router exposing /rps (WebSocket), /rps/sse, and /rps/ack.
Sourcepub fn connected_clients(&self) -> usize
pub fn connected_clients(&self) -> usize
Number of currently connected WebSocket clients.
Sourcepub fn connected_client_ids(&self) -> Vec<Uuid>
pub fn connected_client_ids(&self) -> Vec<Uuid>
All currently connected client IDs.
Sourcepub fn register_handler<F>(&self, channel: C, handler: F)
pub fn register_handler<F>(&self, channel: C, handler: F)
Register a handler for a specific channel. When a frame arrives on this channel, the handler is invoked with the client ID, the frame, and a reference to the server.
Sourcepub async fn upgrade(self: Arc<Self>, ws: WebSocketUpgrade) -> impl IntoResponse
pub async fn upgrade(self: Arc<Self>, ws: WebSocketUpgrade) -> impl IntoResponse
Upgrade an HTTP request to an RPS WebSocket connection.
Sourcepub fn send(&self, client_id: Uuid, frame: Frame<C>) -> Result<(), SendError>
pub fn send(&self, client_id: Uuid, frame: Frame<C>) -> Result<(), SendError>
Push a frame to a connected client.
Sourcepub fn send_binary(
&self,
client_id: Uuid,
channel: C,
bytes: &[u8],
mime: &str,
name: Option<&str>,
pointer_url: Option<&str>,
) -> Result<(), SendError>
pub fn send_binary( &self, client_id: Uuid, channel: C, bytes: &[u8], mime: &str, name: Option<&str>, pointer_url: Option<&str>, ) -> Result<(), SendError>
Send a binary asset using inline-or-pointer logic.
Sourcepub fn send_system(&self, client_id: Uuid, op: SystemOp<C>)
pub fn send_system(&self, client_id: Uuid, op: SystemOp<C>)
Send a system-level message to a client.
Trait Implementations§
Source§impl<C: ChannelKind> Default for PushServer<C>
impl<C: ChannelKind> Default for PushServer<C>
Auto Trait Implementations§
impl<C> Freeze for PushServer<C>
impl<C> !RefUnwindSafe for PushServer<C>
impl<C> Send for PushServer<C>
impl<C> Sync for PushServer<C>
impl<C> Unpin for PushServer<C>
impl<C> UnsafeUnpin for PushServer<C>
impl<C> !UnwindSafe for PushServer<C>
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