···33mod server;
4455pub use matchbox::MatchboxTransport;
66-pub use server::{generate_join_code, room_exists};
66+pub use server::{request_room_code, room_exists};
+12-6
manhunt-transport/src/server.rs
···6666 .await
6767 .context("Could not send request")?
6868 .error_for_status()
6969- .context("Server returned error")?;
6969+ .context("Server returned an error")?;
7070 Ok(())
7171}
72727373-pub fn generate_join_code() -> String {
7474- // 5 character sequence of A-Z
7575- (0..5)
7676- .map(|_| (b'A' + rand::random_range(0..26)) as char)
7777- .collect::<String>()
7373+const SERVER_GEN_CODE_URL: &str = const_str::concat!(SERVER_HTTP_URL, "/gen_code");
7474+7575+pub async fn request_room_code() -> Result<String> {
7676+ reqwest::get(SERVER_GEN_CODE_URL)
7777+ .await
7878+ .context("Failed to contact signaling server")?
7979+ .error_for_status()
8080+ .context("Server returned an error")?
8181+ .text()
8282+ .await
8383+ .context("Failed to decode response")
7884}