pub struct WebSocketRpcSession { /* private fields */ }
Expand description

Client to talk with server via Client API RPC.

Responsible for Room authorization and closing.

Implementations§

source§

impl WebSocketRpcSession

source

pub fn new(client: Rc<WebSocketRpcClient>) -> Rc<Self>

Returns new uninitialized WebSocketRpcSession with a provided WebSocketRpcClient.

Spawns all WebSocketRpcSession task.

Trait Implementations§

source§

impl Debug for WebSocketRpcSession

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl RpcEventHandler for WebSocketRpcSession

source§

fn on_joined_room(&self, room_id: RoomId, member_id: MemberId)

If current SessionState is SessionState::Authorizing and RoomId from ConnectionInfo is equal to the provided RoomId, then SessionState will be transited to the SessionState::Opened.

source§

fn on_left_room(&self, room_id: RoomId, close_reason: CloseReason)

source§

fn on_event(&self, room_id: RoomId, event: Event)

Sends received Event to the all RpcSession::subscribe subscribers if current SessionState is SessionState::Opened and provided RoomId is equal to the RoomId from the ConnectionInfo.

§

type Output = ()

Output type of all functions from this trait.
source§

impl RpcSession for WebSocketRpcSession

source§

fn connect<'async_trait>( self: Rc<Self>, connection_info: ConnectionInfo ) -> Pin<Box<dyn Future<Output = Result<(), Traced<SessionError>>> + 'async_trait>>where Self: 'async_trait,

Tries to connect to the server with a provided ConnectionInfo.

Errors

Errors with SessionError::SessionFinished if current SessionState is SessionState::Finished.

Errors with SessionError if WebSocketRpcSession::connect errors.

source§

fn reconnect<'async_trait>( self: Rc<Self> ) -> Pin<Box<dyn Future<Output = Result<(), Traced<SessionError>>> + 'async_trait>>where Self: 'async_trait,

Tries to reconnect this WebSocketRpcSession to the server.

source§

fn send_command(&self, command: Command)

Sends Command to the server if current SessionState is SessionState::Opened.

source§

fn on_normal_close(&self) -> LocalBoxFuture<'static, CloseReason>

Returns Future which will be resolved when SessionState will be transited to the SessionState::Finished or WebSocketRpcSession will be dropped.

source§

fn close_with_reason(&self, close_reason: ClientDisconnect)

Closes WebSocketRpcSession with a provided ClientDisconnect reason.

SessionState will be transited to the SessionState::Finished.

Provided ClientDisconnect will be provided to the underlying WebSocketRpcClient with WebSocketRpcClient::set_close_reason.

source§

fn on_connection_loss(&self) -> LocalBoxStream<'static, ()>

Returns Stream which will provided Some(()) every time when SessionState goes to the SessionState::Lost.

source§

fn on_reconnected(&self) -> LocalBoxStream<'static, ()>

Returns Stream which will provided Some(()) every time when SessionState goes to the SessionState::Opened.

Nothing will be provided if SessionState goes to the SessionState::Opened first time.

source§

fn subscribe(&self) -> LocalBoxStream<'static, Event>

Returns Stream of all Events received by this RpcSession.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<E> WrapTraced<E> for E

source§

fn wrap_traced(self, f: Frame) -> Traced<E>

Wraps this error into a Traced wrapper, storing the given Frame of a Trace inside.