[−][src]Struct actix_ws::Session
A handle into the websocket session.
This type can be used to send messages into the websocket.
Implementations
impl Session
[src]
pub async fn text<'_, T>(&'_ mut self, msg: T) -> Result<(), Closed> where
T: Into<String>,
[src]
T: Into<String>,
Send text into the websocket
ⓘThis example is not tested
if session.text("Some text").await.is_err() { // session closed }
pub async fn binary<'_, T>(&'_ mut self, msg: T) -> Result<(), Closed> where
T: Into<Bytes>,
[src]
T: Into<Bytes>,
Send raw bytes into the websocket
ⓘThis example is not tested
if session.binary(b"some bytes").await.is_err() { // session closed }
pub async fn ping<'_, '_>(&'_ mut self, msg: &'_ [u8]) -> Result<(), Closed>
[src]
Ping the client
For many applications, it will be important to send regular pings to keep track of if the client has disconnected
ⓘThis example is not tested
if session.ping(b"").await.is_err() { // session is closed }
pub async fn pong<'_, '_>(&'_ mut self, msg: &'_ [u8]) -> Result<(), Closed>
[src]
Pong the client
ⓘThis example is not tested
match msg { Message::Ping(bytes) => { let _ = session.pong(&bytes).await; } _ => (), }
pub async fn close(
__arg0: Self,
reason: Option<CloseReason>
) -> Result<(), Closed>
[src]
__arg0: Self,
reason: Option<CloseReason>
) -> Result<(), Closed>
Send a close message, and consume the session
All clones will return Err(Closed)
if used after this call
ⓘThis example is not tested
session.close(None).await
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl !UnwindSafe for Session
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> Sealed<T> for T where
T: ?Sized,
T: ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,