From 0c9e2e2a0e28f825938fa3f0e8cf0f0cb6780a25 Mon Sep 17 00:00:00 2001 From: Tangent Wantwight Date: Mon, 8 Jun 2020 19:56:48 -0400 Subject: [PATCH] Accurately inform each connected player of their player id --- src/net/server.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/net/server.rs b/src/net/server.rs index e5e8569..742e113 100644 --- a/src/net/server.rs +++ b/src/net/server.rs @@ -13,7 +13,7 @@ use tokio::time::{interval, Instant}; /// the cap is reached. More elegant solutions may be reached in the future. const CHANNEL_BUFFER: usize = 200; -pub async fn greet(sink: &mut Sender) -> Result<()> { +pub async fn greet(sink: &mut Sender, player_id: Option) -> Result<()> { let mut greeting = iter(vec![ ServerMessage::Meta { meta: Meta { @@ -22,7 +22,7 @@ pub async fn greet(sink: &mut Sender) -> Result<()> { }, }, ServerMessage::SetState { - player_id: Some(0), + player_id, state: json!({}), }, ]) @@ -77,7 +77,7 @@ impl Server { }); // connect player - greet(&mut sender).await?; + greet(&mut sender, Some(player_id)).await?; self.players[player_id] = Some(PlayerState { sender }); info!("Client#{} connected", player_id);