pub struct ClientConnection { /* private fields */ }Expand description
Represents a WebSocket client connection
Implementations§
Source§impl ClientConnection
impl ClientConnection
Sourcepub fn new(remote_addr: SocketAddr) -> Self
pub fn new(remote_addr: SocketAddr) -> Self
Create a new client connection
Sourcepub fn remote_addr(&self) -> SocketAddr
pub fn remote_addr(&self) -> SocketAddr
Get the remote address
Sourcepub fn state(&self) -> ConnectionState
pub fn state(&self) -> ConnectionState
Get the connection state
Sourcepub fn metadata(&self) -> &ConnectionMetadata
pub fn metadata(&self) -> &ConnectionMetadata
Get the connection metadata
Sourcepub async fn send_binary(&mut self, data: impl Into<Bytes>) -> Result<()>
pub async fn send_binary(&mut self, data: impl Into<Bytes>) -> Result<()>
Send a binary message
Sourcepub async fn close(
&mut self,
code: Option<u16>,
reason: Option<&str>,
) -> Result<()>
pub async fn close( &mut self, code: Option<u16>, reason: Option<&str>, ) -> Result<()>
Close the connection
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Check if the connection is established
Sourcepub fn set_connected(&mut self)
pub fn set_connected(&mut self)
Set the connection as connected
Sourcepub fn set_subprotocol(&mut self, subprotocol: String)
pub fn set_subprotocol(&mut self, subprotocol: String)
Set the subprotocol
Sourcepub fn add_extension(&mut self, extension: String)
pub fn add_extension(&mut self, extension: String)
Add an extension
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ClientConnection
impl RefUnwindSafe for ClientConnection
impl Send for ClientConnection
impl Sync for ClientConnection
impl Unpin for ClientConnection
impl UnwindSafe for ClientConnection
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