From d1977b95c82f608bc558432cdfba8026aaf0648d Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Thu, 9 Jun 2022 20:57:45 +0200 Subject: consistently use player_key and player_id --- planetwars-server/src/modules/bot_api.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'planetwars-server/src/modules') diff --git a/planetwars-server/src/modules/bot_api.rs b/planetwars-server/src/modules/bot_api.rs index 8aa5d29..4eb13c1 100644 --- a/planetwars-server/src/modules/bot_api.rs +++ b/planetwars-server/src/modules/bot_api.rs @@ -45,15 +45,15 @@ impl PlayerRouter { // TODO: implement a way to expire entries impl PlayerRouter { - fn put(&self, player_id: String, entry: SyncThingData) { + fn put(&self, player_key: String, entry: SyncThingData) { let mut routing_table = self.routing_table.lock().unwrap(); - routing_table.insert(player_id, entry); + routing_table.insert(player_key, entry); } - fn take(&self, player_id: &str) -> Option { + fn take(&self, player_key: &str) -> Option { // TODO: this design does not allow for reconnects. Is this desired? let mut routing_table = self.routing_table.lock().unwrap(); - routing_table.remove(player_id) + routing_table.remove(player_key) } } @@ -66,19 +66,19 @@ impl pb::bot_api_service_server::BotApiService for BotApiServer { req: Request>, ) -> Result, Status> { // TODO: clean up errors - let player_id = req + let player_key = req .metadata() - .get("player_id") - .ok_or_else(|| Status::unauthenticated("no player_id provided"))?; + .get("player_key") + .ok_or_else(|| Status::unauthenticated("no player_key provided"))?; - let player_id_str = player_id + let player_key_str = player_key .to_str() .map_err(|_| Status::invalid_argument("unreadable string"))?; let sync_data = self .router - .take(player_id_str) - .ok_or_else(|| Status::not_found("player_id not found"))?; + .take(player_key_str) + .ok_or_else(|| Status::not_found("player_key not found"))?; let stream = req.into_inner(); -- cgit v1.2.3