Skip to content

Commit 9b115a2

Browse files
committed
rename some stuff to be clearer
1 parent 079069a commit 9b115a2

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

crates/ott-balancer-bin/src/client.rs

+13-10
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl UnauthorizedClient {
2828
}
2929
}
3030

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`].
3232
#[derive(Debug, Clone)]
3333
pub struct NewClient {
3434
pub id: ClientId,
@@ -42,7 +42,7 @@ pub struct ClientLink {
4242
/// Messages to send to the Room this client is in.
4343
room_tx: tokio::sync::mpsc::Sender<Context<ClientId, SocketMessage>>,
4444
/// 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>,
4646
/// Messages sent by the Balancer that need to be sent to this client.
4747
unicast_rx: tokio::sync::mpsc::Receiver<SocketMessage>,
4848
}
@@ -51,13 +51,13 @@ impl ClientLink {
5151
pub fn new(
5252
id: ClientId,
5353
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>,
5555
unicast_rx: tokio::sync::mpsc::Receiver<SocketMessage>,
5656
) -> Self {
5757
Self {
5858
id,
5959
room_tx,
60-
room_rx,
60+
broadcast_rx,
6161
unicast_rx,
6262
}
6363
}
@@ -71,7 +71,7 @@ impl ClientLink {
7171
None => return Err(RecvError::Closed),
7272
}
7373
}
74-
msg = self.room_rx.recv() => {
74+
msg = self.broadcast_rx.recv() => {
7575
msg
7676
}
7777
}?;
@@ -92,22 +92,25 @@ pub struct BalancerClient {
9292
pub id: ClientId,
9393
pub room: RoomName,
9494
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>,
9797
}
9898

9999
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 {
101104
Self {
102105
id: new_client.id,
103106
room: new_client.room,
104107
token: new_client.token,
105-
socket_tx,
108+
unicast_tx,
106109
}
107110
}
108111

109112
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?;
111114

112115
Ok(())
113116
}

0 commit comments

Comments
 (0)