pub struct Session<I, C> {
pub id: I,
/* private fields */
}Available on crate feature
server only.Fields§
§id: IImplementations§
Source§impl<I: Display + Clone, C> Session<I, C>
impl<I: Display + Clone, C> Session<I, C>
Sourcepub fn alive(&self) -> bool
pub fn alive(&self) -> bool
Checks if the Session is still alive, if so you can proceed sending calls or messages.
Sourcepub fn text(
&self,
text: impl Into<Utf8Bytes>,
) -> Result<MessageSignal, SendError<InMessage>>
pub fn text( &self, text: impl Into<Utf8Bytes>, ) -> Result<MessageSignal, SendError<InMessage>>
Sends a Text message to the server
Sourcepub fn binary(
&self,
bytes: impl Into<Bytes>,
) -> Result<MessageSignal, SendError<InMessage>>
pub fn binary( &self, bytes: impl Into<Bytes>, ) -> Result<MessageSignal, SendError<InMessage>>
Sends a Binary message to the server
Sourcepub async fn call_with<R: Debug>(
&self,
f: impl FnOnce(Sender<R>) -> C,
) -> Option<R>
pub async fn call_with<R: Debug>( &self, f: impl FnOnce(Sender<R>) -> C, ) -> Option<R>
Calls a method on the session, allowing the Session to respond with oneshot::Sender. This is just for easier construction of the call which happen to contain oneshot::Sender in it.
Sourcepub fn close(
&self,
frame: Option<CloseFrame>,
) -> Result<MessageSignal, SendError<InMessage>>
pub fn close( &self, frame: Option<CloseFrame>, ) -> Result<MessageSignal, SendError<InMessage>>
Close the session. Returns an error if the session is already closed.
Trait Implementations§
Auto Trait Implementations§
impl<I, C> Freeze for Session<I, C>where
I: Freeze,
impl<I, C> !RefUnwindSafe for Session<I, C>
impl<I, C> Send for Session<I, C>
impl<I, C> Sync for Session<I, C>
impl<I, C> Unpin for Session<I, C>where
I: Unpin,
impl<I, C> !UnwindSafe for Session<I, C>
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