From 7128e45af0d1be2fc5fdd15720f93c65cac21dc9 Mon Sep 17 00:00:00 2001 From: ghostlyzsh Date: Tue, 11 Apr 2023 22:44:05 -0500 Subject: [PATCH] alright lets go stuff broke again --- client/src/lib.rs | 2 ++ server/src/handler.rs | 3 ++- web/play.html | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/client/src/lib.rs b/client/src/lib.rs index 41b07e8e9fc429a82cfad60db59d5c9cade33001..8f6e234c73a0a5c8d68f7b01cc73c51dd34bcf48 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -5,6 +5,7 @@ use futures::stream::{SplitSink, SplitStream}; use futures::{StreamExt, TryFutureExt}; use log::{debug, error, info, Level, trace, warn}; use wasm_bindgen::prelude::*; +use web_sys::console::debug; use ws_stream_wasm::{WsErr, WsMessage, WsMeta, WsStream}; use starkingdoms_protocol::{ProtocolPlanet, State}; use starkingdoms_protocol::PROTOCOL_VERSION; @@ -235,6 +236,7 @@ pub async fn update_socket() -> Result<(), JsError> { chatbox.append_child(&new_elem).unwrap(); }, MessageS2C::Pong {} => { + info!("this is a pong response"); client_data.pong_timeout = (js_sys::Date::now() as u64 / 1000) + PONG_MAX_TIMEOUT }, MessageS2C::PlanetData { planets } => { diff --git a/server/src/handler.rs b/server/src/handler.rs index f7ac231e420c44fd0c290d5e2927e0b362a94b15..868b0110a9e91e571baaa7c7ed91b7c412317ed8 100644 --- a/server/src/handler.rs +++ b/server/src/handler.rs @@ -1,7 +1,7 @@ use std::error::Error; use std::net::SocketAddr; use std::sync::Arc; -use std::time::{Duration, SystemTime}; +use std::time::{Duration, SystemTime, UNIX_EPOCH}; use futures::stream::{SplitSink, SplitStream}; use futures::{FutureExt, SinkExt, StreamExt}; use hyper::upgrade::Upgraded; @@ -23,6 +23,7 @@ pub async fn handle_client(mgr: ClientManager, data: Arc>, r let mut ping_timeout = SystemTime::now() + Duration::from_secs(5); loop { + info!("{}", ping_timeout.duration_since(UNIX_EPOCH).unwrap().as_secs() - SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs()); if let Some(msg) = rx.recv().await { match msg { ClientHandlerMessage::Tick => {} // this intentionally does nothing, diff --git a/web/play.html b/web/play.html index 698670758bd7e643cb5f178f414013620c6a17ed..4aef66765d1a2d6be7560a542d2c506233632340 100644 --- a/web/play.html +++ b/web/play.html @@ -56,10 +56,10 @@ render_frame(delta); start = time; - requestAnimationFrame(animateFrame) + //requestAnimationFrame(animateFrame) } - requestAnimationFrame(animateFrame); + //requestAnimationFrame(animateFrame); if (urlSearchParams.has("showTextures")) { let textures = ["autoplr_cfg", "autoplr_error", "autoplr_on", "cargo_off", "cargo_on", "earth", "ecothruster_on", "hearty", "hub_off", "hub_on", "landingleg", "landingthruster_off", "landingthruster_on", "powerhub_off", "powerhub_on", "superthruster_off", "superthruster_on", "thruster_off", "thruster_on"]; @@ -85,4 +85,4 @@ }) - \ No newline at end of file +