From 4e5ccd604c78a9698ebf2e4d49d3dec62a9d752c Mon Sep 17 00:00:00 2001 From: Nikita Vilunov Date: Tue, 14 Feb 2023 20:45:22 +0100 Subject: [PATCH] rename socket => connection for consistency --- src/core/player.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/core/player.rs b/src/core/player.rs index 59ea849..cf1969e 100644 --- a/src/core/player.rs +++ b/src/core/player.rs @@ -79,7 +79,7 @@ impl PlayerHandle { let (sender, receiver) = channel(32); let (promise, deferred) = oneshot(); self.tx - .send(PlayerCommand::AddSocket { sender, promise }) + .send(PlayerCommand::AddConnection { sender, promise }) .await; let connection_id = deferred.await.unwrap(); PlayerConnection { @@ -126,7 +126,7 @@ impl PlayerHandle { pub enum PlayerCommand { /** Commands from connections */ - AddSocket { + AddConnection { sender: Sender, promise: OneshotSender, }, @@ -186,7 +186,7 @@ impl PlayerRegistry { pub async fn get_or_create_player(&mut self, id: PlayerId) -> PlayerHandle { let player = Player { - sockets: AnonTable::new(), + connections: AnonTable::new(), }; let mut inner = self.0.write().unwrap(); if let Some((handle, _)) = inner.players.get(&id) { @@ -214,7 +214,7 @@ struct PlayerRegistryInner { /// Player actor inner state representation. struct Player { - sockets: AnonTable>, + connections: AnonTable>, } impl Player { fn launch( @@ -229,8 +229,8 @@ impl Player { let fiber = tokio::task::spawn(async move { while let Some(cmd) = rx.recv().await { match cmd { - PlayerCommand::AddSocket { sender, promise } => { - let connection_id = self.sockets.insert(sender); + PlayerCommand::AddConnection { sender, promise } => { + let connection_id = self.connections.insert(sender); promise.send(ConnectionId(connection_id)); } PlayerCommand::JoinRoom { @@ -275,10 +275,10 @@ impl Player { PlayerCommand::Update(update) => { log::info!( "Player received an update, broadcasting to {} connections", - self.sockets.len() + self.connections.len() ); - for socket in &self.sockets { - socket.send(update.clone()).await; + for connection in &self.connections { + connection.send(update.clone()).await; } } }