pub struct Client {
pub id: ClientId,
pub metadata: ClientMetadata,
/* private fields */
}Expand description
A connected WebSocket client.
Fields§
§id: ClientIdUnique client identifier.
metadata: ClientMetadataConnection metadata.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(id: ClientId, sender: UnboundedSender<String>) -> Self
pub fn new(id: ClientId, sender: UnboundedSender<String>) -> Self
Create a new client with a message sender.
Sourcepub fn send(&self, message: String) -> Result<(), RealtimeError>
pub fn send(&self, message: String) -> Result<(), RealtimeError>
Send a message to this client.
Sourcepub fn subscribe(&self, channel: Channel) -> Result<bool, RealtimeError>
pub fn subscribe(&self, channel: Channel) -> Result<bool, RealtimeError>
Subscribe to a channel.
Sourcepub fn unsubscribe(&self, channel: &Channel) -> bool
pub fn unsubscribe(&self, channel: &Channel) -> bool
Unsubscribe from a channel.
Sourcepub fn is_subscribed(&self, channel: &Channel) -> bool
pub fn is_subscribed(&self, channel: &Channel) -> bool
Check if subscribed to a channel.
Sourcepub fn matches_event(&self, event_channel: &str) -> bool
pub fn matches_event(&self, event_channel: &str) -> bool
Check if any subscription matches an event channel.
Sourcepub fn subscription_count(&self) -> usize
pub fn subscription_count(&self) -> usize
Get subscription count.
Sourcepub fn clear_subscriptions(&self)
pub fn clear_subscriptions(&self)
Clear all subscriptions.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnwindSafe for Client
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