pub struct Connection { /* private fields */ }Expand description
WebSocket connection
Implementations§
Source§impl Connection
impl Connection
Sourcepub fn new(
ws: WebSocketStream<TcpStream>,
remote_addr: SocketAddr,
codec: ProtocolCodec,
) -> (Self, UnboundedReceiver<Message>)
pub fn new( ws: WebSocketStream<TcpStream>, remote_addr: SocketAddr, codec: ProtocolCodec, ) -> (Self, UnboundedReceiver<Message>)
Create a new connection
Sourcepub fn id(&self) -> ConnectionId
pub fn id(&self) -> ConnectionId
Get connection ID
Sourcepub fn remote_addr(&self) -> SocketAddr
pub fn remote_addr(&self) -> SocketAddr
Get remote address
Sourcepub async fn state(&self) -> ConnectionState
pub async fn state(&self) -> ConnectionState
Get connection state
Sourcepub async fn set_state(&self, new_state: ConnectionState)
pub async fn set_state(&self, new_state: ConnectionState)
Set connection state
Sourcepub async fn process_outgoing(
&self,
rx: UnboundedReceiver<Message>,
) -> Result<()>
pub async fn process_outgoing( &self, rx: UnboundedReceiver<Message>, ) -> Result<()>
Process outgoing messages
Sourcepub async fn metadata(&self) -> ConnectionMetadata
pub async fn metadata(&self) -> ConnectionMetadata
Get metadata
Sourcepub async fn update_metadata<F>(&self, f: F)where
F: FnOnce(&mut ConnectionMetadata),
pub async fn update_metadata<F>(&self, f: F)where
F: FnOnce(&mut ConnectionMetadata),
Update metadata
Sourcepub fn last_activity(&self) -> u64
pub fn last_activity(&self) -> u64
Get last activity timestamp
Sourcepub fn stats(&self) -> ConnectionStats
pub fn stats(&self) -> ConnectionStats
Get statistics
Auto Trait Implementations§
impl Freeze for Connection
impl !RefUnwindSafe for Connection
impl Send for Connection
impl Sync for Connection
impl Unpin for Connection
impl UnsafeUnpin for Connection
impl !UnwindSafe for Connection
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