pub struct WsClient { /* private fields */ }Expand description
A cheap, clonable handle to one connected client.
Passed to every gateway lifecycle hook and #[Subscribe] handler. All
methods are non-blocking and lock-free on the hot path: emitting just
enqueues onto a sharded channel. Holds a &'static ConnectionRegistry, so
cloning is a pointer copy — no Arc refcount traffic for the registry.
Implementations§
Source§impl WsClient
impl WsClient
Sourcepub fn claims(&self) -> Option<&Claims>
pub fn claims(&self) -> Option<&Claims>
Session claims captured during the handshake (e.g. decoded JWT), if any.
Sourcepub async fn emit<T: Serialize>(&self, event: &str, payload: T)
pub async fn emit<T: Serialize>(&self, event: &str, payload: T)
Send an event to this client only.
Sourcepub async fn broadcast<T: Serialize>(&self, event: &str, payload: T)
pub async fn broadcast<T: Serialize>(&self, event: &str, payload: T)
Broadcast an event to every connected client (including self).
Sourcepub async fn broadcast_to_room<T: Serialize>(
&self,
room: &str,
event: &str,
payload: T,
)
pub async fn broadcast_to_room<T: Serialize>( &self, room: &str, event: &str, payload: T, )
Broadcast an event to every client currently in room.
Sourcepub fn join_room(&self, room: impl Into<String>)
pub fn join_room(&self, room: impl Into<String>)
Join a logical room/channel. Subsequent room broadcasts reach this client.
Sourcepub fn leave_room(&self, room: &str)
pub fn leave_room(&self, room: &str)
Leave a room.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for WsClient
impl !UnwindSafe for WsClient
impl Freeze for WsClient
impl Send for WsClient
impl Sync for WsClient
impl Unpin for WsClient
impl UnsafeUnpin for WsClient
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request