1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
pub mod client;
pub mod control;
use std::fmt::Debug;
use actix::MailboxError;
use futures::future::LocalBoxFuture;
use medea_client_api_proto::{Command, Credential, MemberId};
use crate::{
api::client::rpc_connection::{
ClosedReason, RpcConnection, RpcConnectionSettings,
},
signalling::room::RoomError,
};
#[derive(Debug)]
pub enum RpcServerError {
Authorization,
RoomError(RoomError),
RoomMailbox(MailboxError),
}
impl From<RoomError> for RpcServerError {
fn from(err: RoomError) -> Self {
match &err {
RoomError::AuthorizationError => Self::Authorization,
_ => Self::RoomError(err),
}
}
}
#[cfg_attr(test, mockall::automock)]
pub trait RpcServer: Debug + Send {
fn connection_established(
&self,
member_id: MemberId,
credential: Credential,
connection: Box<dyn RpcConnection>,
) -> LocalBoxFuture<'static, Result<RpcConnectionSettings, RpcServerError>>;
fn connection_closed(
self: Box<Self>,
member_id: MemberId,
reason: ClosedReason,
) -> LocalBoxFuture<'static, ()>;
fn send_command(&self, member_id: MemberId, msg: Command);
fn synchronize(&self, member_id: MemberId) -> LocalBoxFuture<'static, ()>;
}
#[cfg(test)]
impl_debug_by_struct_name!(MockRpcServer);