pub struct MessageContext {
pub connection_id: String,
/* private fields */
}Expand description
消息处理上下文
提供给消息处理函数的上下文,包含连接信息和服务器操作处理器
Fields§
§connection_id: String连接 ID
Implementations§
Source§impl MessageContext
impl MessageContext
Sourcepub async fn broadcast_except(
&self,
frame: &Frame,
exclude_connection_id: &str,
) -> Result<()>
pub async fn broadcast_except( &self, frame: &Frame, exclude_connection_id: &str, ) -> Result<()>
广播消息到所有连接,排除指定连接
Sourcepub async fn disconnect(&self, connection_id: &str) -> Result<()>
pub async fn disconnect(&self, connection_id: &str) -> Result<()>
断开指定连接
Sourcepub fn connection_count(&self) -> usize
pub fn connection_count(&self) -> usize
获取连接数量
Sourcepub fn user_count(&self) -> usize
pub fn user_count(&self) -> usize
获取用户数量
Auto Trait Implementations§
impl !RefUnwindSafe for MessageContext
impl !UnwindSafe for MessageContext
impl Freeze for MessageContext
impl Send for MessageContext
impl Sync for MessageContext
impl Unpin for MessageContext
impl UnsafeUnpin for MessageContext
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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