diff options
Diffstat (limited to 'server/src/main.rs')
-rw-r--r-- | server/src/main.rs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/server/src/main.rs b/server/src/main.rs index f81ee38c..90d090d8 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -18,7 +18,7 @@ use anyhow::{anyhow, Result}; use clap::Parser; use futures_util::{SinkExt, StreamExt}; -use hurrycurry_protocol::{PacketC, PacketS, PlayerID}; +use hurrycurry_protocol::{PacketC, PacketS, PlayerID, VERSION}; use hurrycurry_server::{data::DATA_DIR, state::State}; use log::{debug, info, trace, warn, LevelFilter}; use std::{path::PathBuf, process::exit, str::FromStr, sync::Arc, time::Duration}; @@ -108,13 +108,22 @@ async fn run() -> anyhow::Result<()> { warn!("invalid ws handshake"); continue; }; + info!("{addr} connected via websocket"); + let (mut write, mut read) = sock.split(); let state = state.clone(); let mut rx = rx.resubscribe(); let (error_tx, mut error_rx) = channel::<PacketC>(8); - info!("{addr} connected via websocket"); + let mut init = state.write().await.game.prime_client(); - init.insert(0, PacketC::Init { id }); + init.insert( + 0, + PacketC::Version { + major: VERSION.0, + minor: VERSION.1, + }, + ); + init.insert(1, PacketC::Init { id }); spawn(async move { for p in init { if let Err(e) = write |