Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't send packets unless joined #53

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,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 @@ -120,7 +123,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 @@ -134,7 +138,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
Loading