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
impl WebSocketRpcSession
Sourcepub fn new(client: Rc<WebSocketRpcClient>) -> Rc<Self>
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
impl Debug for WebSocketRpcSession
Source§impl RpcEventHandler for WebSocketRpcSession
impl RpcEventHandler for WebSocketRpcSession
Source§fn on_joined_room(&self, room_id: RoomId, member_id: MemberId)
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)
fn on_left_room(&self, room_id: RoomId, close_reason: CloseReason)
If current SessionState
is SessionState::Opened
or
SessionState::Authorizing
and provided RoomId
is
equal to the RoomId
from the ConnectionInfo
of this
WebSocketRpcSession
, then SessionState
will be transited
to the SessionState::Finished
if current SessionState
is
SessionState::Opened
or to the SessionState::Uninitialized
if
current SessionState
is SessionState::Authorizing
.
Source§fn on_event(&self, room_id: RoomId, event: Event)
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
.
Source§impl RpcSession for WebSocketRpcSession
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,
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,
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)
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>
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)
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, ()>
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, ()>
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.