Skip to content

Commit

Permalink
Don't send packets unless joined
Browse files Browse the repository at this point in the history
Fixes #47
  • Loading branch information
Erb3 committed Jun 3, 2024
1 parent cb7e9ac commit d2dd561
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ pub fn on_connect(socket: SocketRef) {
},
)
.unwrap();

socket.join("PRIMARY").unwrap();

info!(
"🪪 Client with ID {} set username to {}",
socket.id, data.username
Expand Down Expand Up @@ -142,7 +145,8 @@ pub async fn game_loop(
leaderboard: state.leaderboard.clone(),
};

io.emit("solution", solution)
io.to("PRIMARY")
.emit("solution", solution)
.expect("Unable to broadcast solution");
}

Expand All @@ -156,7 +160,8 @@ pub async fn game_loop(

info!("📍 New location: {}, {}", &city.name, &city.country);
game_state.lock().unwrap().guesses.clear();
io.emit("newTarget", target_message)
io.to("PRIMARY")
.emit("newTarget", target_message)
.expect("Unable to broadcast new target");

last_city = Some(city);
Expand Down

0 comments on commit d2dd561

Please sign in to comment.