Struct medea_jason::rpc::WebSocketRpcSession
source · 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.