From bb6e4c6acf221f1f17c5cd25714ec438f9b0db2d Mon Sep 17 00:00:00 2001 From: Adam <24621027+adoyle0@users.noreply.github.com> Date: Sat, 4 May 2024 02:49:17 -0400 Subject: [PATCH] order things --- src/api.rs | 20 ++++++++++---------- src/main.rs | 18 +++++++++--------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/api.rs b/src/api.rs index 804fbf1..8ac3b2d 100644 --- a/src/api.rs +++ b/src/api.rs @@ -20,16 +20,6 @@ fn greeting(state: &Arc) -> String { ) } -pub async fn websocket_handler( - ws: WebSocketUpgrade, - // user_agent: Option>, - ConnectInfo(addr): ConnectInfo, - State(state): State>, -) -> impl IntoResponse { - tracing::debug!("New connection from {addr}"); - ws.on_upgrade(move |socket| websocket(socket, state, addr)) -} - pub async fn websocket(stream: WebSocket, state: Arc, who: SocketAddr) { // By splitting, we can send and receive at the same time. let (mut sender, mut receiver) = stream.split(); @@ -66,3 +56,13 @@ pub async fn websocket(stream: WebSocket, state: Arc, who: SocketAddr) _ = (&mut recv_task) => send_task.abort(), }; } + +pub async fn websocket_handler( + ws: WebSocketUpgrade, + // user_agent: Option>, + ConnectInfo(addr): ConnectInfo, + State(state): State>, +) -> impl IntoResponse { + tracing::debug!("New connection from {addr}"); + ws.on_upgrade(move |socket| websocket(socket, state, addr)) +} diff --git a/src/main.rs b/src/main.rs index 9f75aab..730c13f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -86,6 +86,15 @@ pub struct AppState { games: Mutex>, } +// Include utf-8 file at **compile** time. +async fn index() -> Html<&'static str> { + Html(std::include_str!("../test_client.html")) +} + +async fn spawnclients() -> Html<&'static str> { + Html(std::include_str!("../spawnclients.html")) +} + #[tokio::main] async fn main() -> Result<(), Box> { tracing_subscriber::registry() @@ -125,12 +134,3 @@ async fn main() -> Result<(), Box> { Ok(()) } - -// Include utf-8 file at **compile** time. -async fn index() -> Html<&'static str> { - Html(std::include_str!("../test_client.html")) -} - -async fn spawnclients() -> Html<&'static str> { - Html(std::include_str!("../spawnclients.html")) -}