pub struct WebSocketRpcClient(/* private fields */);
Expand description
Client API RPC client to talk with server via WebSocket.
Implementations§
Source§impl WebSocketRpcClient
impl WebSocketRpcClient
Sourcepub fn new(rpc_transport_factory: RpcTransportFactory) -> Self
pub fn new(rpc_transport_factory: RpcTransportFactory) -> Self
Creates new WebSocketRpcClient
with provided RpcTransportFactory
closure.
Sourcepub fn join_room(
&self,
room_id: RoomId,
member_id: MemberId,
credential: Credential,
capabilities: Capabilities,
)
pub fn join_room( &self, room_id: RoomId, member_id: MemberId, credential: Credential, capabilities: Capabilities, )
Authorizes WebSocketRpcClient
on the Media Server.
Sourcepub fn leave_room(&self, room_id: RoomId, member_id: MemberId)
pub fn leave_room(&self, room_id: RoomId, member_id: MemberId)
Leaves Room
with a provided RoomId
.
Sourcepub async fn connect(
self: Rc<Self>,
url: ApiUrl,
) -> Result<(), Traced<RpcClientError>>
pub async fn connect( self: Rc<Self>, url: ApiUrl, ) -> Result<(), Traced<RpcClientError>>
Tries to upgrade ClientState
of this WebSocketRpcClient
to
ClientState::Open
.
This function is also used for reconnecting this WebSocketRpcClient
.
If WebSocketRpcClient
is closed than this function will try to
establish new RPC connection.
If WebSocketRpcClient
already in ClientState::Connecting
then
this function will not perform one more connection try. It will
subscribe to ClientState
changes and wait for first connection
result, and, based on this result, this function will be resolved.
If WebSocketRpcClient
already in ClientState::Open
then this
function will be instantly resolved.
§Errors
Errors if WebSocketRpcClient
fails to establish connection with a
server.
Sourcepub fn subscribe(&self) -> LocalBoxStream<'static, RpcEvent>
pub fn subscribe(&self) -> LocalBoxStream<'static, RpcEvent>
Subscribes on this WebSocketRpcClient
’s RpcEvent
s.
Sourcepub fn send_command(&self, room_id: RoomId, command: Command)
pub fn send_command(&self, room_id: RoomId, command: Command)
Sourcepub fn on_normal_close(
&self,
) -> LocalBoxFuture<'static, Result<CloseReason, Canceled>>
pub fn on_normal_close( &self, ) -> LocalBoxFuture<'static, Result<CloseReason, Canceled>>
Future
resolving on normal WebSocketRpcClient
connection
closing.
This Future
wouldn’t be resolved on abnormal closes.
An WebSocketRpcClient::on_connection_loss
will be thrown instead.
Sourcepub fn on_connection_loss(
&self,
) -> LocalBoxStream<'static, ConnectionLostReason>
pub fn on_connection_loss( &self, ) -> LocalBoxStream<'static, ConnectionLostReason>
Subscribe to connection loss events.
Connection loss is any unexpected platform::RpcTransport
close. In
case of connection loss, client side user should select reconnection
strategy with ReconnectHandle
(or simply close Room
).
Sourcepub fn set_close_reason(&self, close_reason: ClientDisconnect)
pub fn set_close_reason(&self, close_reason: ClientDisconnect)
Sets reason being passed to the underlying transport when this client is dropped.