aboutsummaryrefslogtreecommitdiff
path: root/planetwars-server
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2022-06-09 20:57:45 +0200
committerIlion Beyst <ilion.beyst@gmail.com>2022-06-09 20:57:45 +0200
commitd1977b95c82f608bc558432cdfba8026aaf0648d (patch)
tree2e23b6553b444dc2e93130c035cf738c0e5a07a8 /planetwars-server
parente3cf0df4509fe5cb0ad114040f52f61436a6663f (diff)
downloadplanetwars.dev-d1977b95c82f608bc558432cdfba8026aaf0648d.tar.xz
planetwars.dev-d1977b95c82f608bc558432cdfba8026aaf0648d.zip
consistently use player_key and player_id
Diffstat (limited to 'planetwars-server')
-rw-r--r--planetwars-server/src/modules/bot_api.rs20
1 files changed, 10 insertions, 10 deletions
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<SyncThingData> {
+ fn take(&self, player_key: &str) -> Option<SyncThingData> {
// 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<Streaming<pb::PlayerRequestResponse>>,
) -> Result<Response<Self::ConnectBotStream>, 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();