pub struct Sender { /* private fields */ }Expand description
消息发送器
Implementations§
Source§impl Sender
impl Sender
Sourcepub async fn register(
&self,
connection_id: ConnectionId,
sender: UnboundedSender<Message>,
)
pub async fn register( &self, connection_id: ConnectionId, sender: UnboundedSender<Message>, )
注册连接的发送通道
Sourcepub async fn unregister(&self, connection_id: &str)
pub async fn unregister(&self, connection_id: &str)
注销连接的发送通道
Sourcepub async fn send_to(
&self,
connection_id: &str,
message: Message,
) -> WebSocketResult<()>
pub async fn send_to( &self, connection_id: &str, message: Message, ) -> WebSocketResult<()>
发送消息到指定连接
Sourcepub async fn broadcast(&self, message: Message) -> WebSocketResult<usize>
pub async fn broadcast(&self, message: Message) -> WebSocketResult<usize>
广播消息到所有连接
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Sender
impl !RefUnwindSafe for Sender
impl Send for Sender
impl Sync for Sender
impl Unpin for Sender
impl UnsafeUnpin for Sender
impl !UnwindSafe for Sender
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