@@ -28,7 +28,7 @@ impl UnauthorizedClient {
28
28
}
29
29
}
30
30
31
- /// Represents a client websocket connection's context. Used by [`OttBalancer `] to make a [`BalancerClient`].
31
+ /// Represents a client websocket connection's context. Used by [`crate::Balancer `] to make a [`BalancerClient`].
32
32
#[ derive( Debug , Clone ) ]
33
33
pub struct NewClient {
34
34
pub id : ClientId ,
@@ -42,7 +42,7 @@ pub struct ClientLink {
42
42
/// Messages to send to the Room this client is in.
43
43
room_tx : tokio:: sync:: mpsc:: Sender < Context < ClientId , SocketMessage > > ,
44
44
/// Messages sent by the Balancer that need to be sent to all clients in the same room as this client.
45
- room_rx : tokio:: sync:: broadcast:: Receiver < SocketMessage > ,
45
+ broadcast_rx : tokio:: sync:: broadcast:: Receiver < SocketMessage > ,
46
46
/// Messages sent by the Balancer that need to be sent to this client.
47
47
unicast_rx : tokio:: sync:: mpsc:: Receiver < SocketMessage > ,
48
48
}
@@ -51,13 +51,13 @@ impl ClientLink {
51
51
pub fn new (
52
52
id : ClientId ,
53
53
room_tx : tokio:: sync:: mpsc:: Sender < Context < ClientId , SocketMessage > > ,
54
- room_rx : tokio:: sync:: broadcast:: Receiver < SocketMessage > ,
54
+ broadcast_rx : tokio:: sync:: broadcast:: Receiver < SocketMessage > ,
55
55
unicast_rx : tokio:: sync:: mpsc:: Receiver < SocketMessage > ,
56
56
) -> Self {
57
57
Self {
58
58
id,
59
59
room_tx,
60
- room_rx ,
60
+ broadcast_rx ,
61
61
unicast_rx,
62
62
}
63
63
}
@@ -71,7 +71,7 @@ impl ClientLink {
71
71
None => return Err ( RecvError :: Closed ) ,
72
72
}
73
73
}
74
- msg = self . room_rx . recv( ) => {
74
+ msg = self . broadcast_rx . recv( ) => {
75
75
msg
76
76
}
77
77
} ?;
@@ -92,22 +92,25 @@ pub struct BalancerClient {
92
92
pub id : ClientId ,
93
93
pub room : RoomName ,
94
94
pub token : String ,
95
- /// The Sender used to send messages to this client.
96
- socket_tx : tokio:: sync:: mpsc:: Sender < SocketMessage > ,
95
+ /// The Sender used to send outbound messages to this client.
96
+ unicast_tx : tokio:: sync:: mpsc:: Sender < SocketMessage > ,
97
97
}
98
98
99
99
impl BalancerClient {
100
- pub fn new ( new_client : NewClient , socket_tx : tokio:: sync:: mpsc:: Sender < SocketMessage > ) -> Self {
100
+ pub fn new (
101
+ new_client : NewClient ,
102
+ unicast_tx : tokio:: sync:: mpsc:: Sender < SocketMessage > ,
103
+ ) -> Self {
101
104
Self {
102
105
id : new_client. id ,
103
106
room : new_client. room ,
104
107
token : new_client. token ,
105
- socket_tx ,
108
+ unicast_tx ,
106
109
}
107
110
}
108
111
109
112
pub async fn send ( & self , msg : impl Into < SocketMessage > ) -> anyhow:: Result < ( ) > {
110
- self . socket_tx . send ( msg. into ( ) ) . await ?;
113
+ self . unicast_tx . send ( msg. into ( ) ) . await ?;
111
114
112
115
Ok ( ( ) )
113
116
}
0 commit comments