diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-08 03:29:35 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-08 03:29:35 +0100 |
| commit | 058432130628d00764663ecf819a9adc6793768d (patch) | |
| tree | d3f49f111fbfaa48647cca2600adcf9017af2d30 /gui/src/app.rs | |
| parent | web: serve latest.php through PHP and refuse stray PHP files (diff) | |
| download | zagan-bet-058432130628d00764663ecf819a9adc6793768d.tar.gz zagan-bet-058432130628d00764663ecf819a9adc6793768d.zip | |
v5.0.0: protocol v5 and the browser frontend
Protocol v5 replaces newline lines with bounded [u32 len][text] frames and REQ/RES/EVT envelopes. Requests carry correlation ids and the server replays the last 256 replies per connection, so a gateway retry cannot double-debit and a late reply cannot clobber a newer request. HELLO/PONG carry server time; crash rounds announce started_at and push coalesced 10 Hz ticks. Crash now commits sha256(seed) before a round and reveals the seed when it ends, so clients recompute the crash point.
Adds the webd/ gateway: one blocking thread, one ClientCore and one pinned upstream TLS connection per session, an HttpOnly session cookie, takeover, and a 60-second grace window. The browser sends Command JSON and renders View JSON; it never speaks the game protocol or stores credentials.
Adds the vanilla TypeScript browser app at /play/ (login, lobby, all four games, history, notices, crash verification), the nginx /play and /ws routes, and the headless DOM smoke test. webd and the app stay out of the TUI/GUI/server build graph.
The client/server version moves to 5.0.0 in lockstep; v4 peers are refused at HELLO.
Diffstat (limited to '')
| -rw-r--r-- | gui/src/app.rs | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/gui/src/app.rs b/gui/src/app.rs index af64e5e..df8fec3 100644 --- a/gui/src/app.rs +++ b/gui/src/app.rs | |||
| @@ -16,6 +16,7 @@ use zagan_bet::client::database; | |||
| 16 | use zagan_bet::client::paths; | 16 | use zagan_bet::client::paths; |
| 17 | use zagan_bet::client::view::{Command, LobbyView, View}; | 17 | use zagan_bet::client::view::{Command, LobbyView, View}; |
| 18 | use zagan_bet::history::PlayRecord; | 18 | use zagan_bet::history::PlayRecord; |
| 19 | use zagan_bet::protocol::Packet; | ||
| 19 | use zagan_bet::version::{VERSION, is_newer}; | 20 | use zagan_bet::version::{VERSION, is_newer}; |
| 20 | 21 | ||
| 21 | use crate::net::{Command as NetCommand, Connected, Event, Failure, Network}; | 22 | use crate::net::{Command as NetCommand, Connected, Event, Failure, Network}; |
| @@ -280,8 +281,8 @@ impl ZaganApp { | |||
| 280 | } | 281 | } |
| 281 | } | 282 | } |
| 282 | } | 283 | } |
| 283 | Effect::SendLine(line) => { | 284 | Effect::SendRequest { id, payload } => { |
| 284 | self.net.send(NetCommand::Send(line)); | 285 | self.net.send(NetCommand::Send { id, payload }); |
| 285 | self.awaiting = Some(Instant::now()); | 286 | self.awaiting = Some(Instant::now()); |
| 286 | } | 287 | } |
| 287 | Effect::Disconnect => { | 288 | Effect::Disconnect => { |
| @@ -355,17 +356,18 @@ impl ZaganApp { | |||
| 355 | failure, | 356 | failure, |
| 356 | message, | 357 | message, |
| 357 | } => self.failed(addr, failure, message), | 358 | } => self.failed(addr, failure, message), |
| 358 | Event::Line(line) => { | 359 | Event::Packet(packet) => match packet { |
| 359 | if self.core.is_async(&line) { | 360 | Packet::Event { body, .. } => { |
| 360 | if let Some(effects) = self.core.handle_async_line(&line) { | 361 | if let Some(effects) = self.core.handle_async_line(&body) { |
| 361 | self.apply(ctx, effects); | 362 | self.apply(ctx, effects); |
| 362 | } | 363 | } |
| 363 | } else { | 364 | } |
| 365 | Packet::Reply { id, body } => { | ||
| 364 | self.awaiting = None; | 366 | self.awaiting = None; |
| 365 | let effects = self.core.handle_reply(&line); | 367 | let effects = self.core.handle_reply_id(id, &body); |
| 366 | self.apply(ctx, effects); | 368 | self.apply(ctx, effects); |
| 367 | } | 369 | } |
| 368 | } | 370 | }, |
| 369 | Event::Closed => { | 371 | Event::Closed => { |
| 370 | self.session = None; | 372 | self.session = None; |
| 371 | self.awaiting = None; | 373 | self.awaiting = None; |
| @@ -384,6 +386,7 @@ impl ZaganApp { | |||
| 384 | self.core | 386 | self.core |
| 385 | .set_host_info(Some(connected.addr.clone()), connected.fingerprint.clone()); | 387 | .set_host_info(Some(connected.addr.clone()), connected.fingerprint.clone()); |
| 386 | self.core.set_logged_in(connected.user.clone()); | 388 | self.core.set_logged_in(connected.user.clone()); |
| 389 | self.core.set_server_time(connected.server_time); | ||
| 387 | self.login.error = connected.auth_error.clone(); | 390 | self.login.error = connected.auth_error.clone(); |
| 388 | self.login.user = connected.user.clone().unwrap_or_default(); | 391 | self.login.user = connected.user.clone().unwrap_or_default(); |
| 389 | 392 | ||
