R4: push enrichment — events carry a state delta, kill the last poll
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 13s
CI / ui (pull_request) Successful in 37s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m8s
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 13s
CI / ui (pull_request) Successful in 37s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m8s
Enrich the in-app live stream into a delta channel so the UI renders a move from the event without a follow-up game.state, and make the matchmaking poll a stream-down fallback. - pkg/fbs: trailing fields on opponent_moved (move+game+bag_len), your_turn (move_count), match_found (state), game_over (game), notify (account/invitation/state), MoveResult (rack+bag_len); regenerate Go + TS. - backend: notify owns the FB encoding (encode.go + payload.go input structs); game/lobby/social map their domain types in. emitMove builds the move delta; game.Service.InitialState feeds match_found/game_started the recipient's initial StateView; friends/invitations notify carry their account/invitation. The move-commit response (submit_play/pass/exchange/resign) returns the actor's refilled rack + bag size. - gateway: MoveResult transcode carries rack+bag_len. - ui: pure lib/gamedelta.ts reducer advances the per-game cache keyed on move_count (idempotent + gap-safe); app.svelte seeds the cache on match_found/game_started; Game.svelte applies the delta (commit/pass/exchange/resign drop their load()); NewGame polls only while app.streamAlive is false. - docs: ARCHITECTURE §10, FUNCTIONAL(+ru), backend/gateway/ui READMEs; PRERELEASE R4 marked done + Refinements.
This commit is contained in:
+35
-7
@@ -159,10 +159,16 @@ table SubmitPlayRequest {
|
||||
tiles:[PlayTile];
|
||||
}
|
||||
|
||||
// MoveResult is the outcome of a committed move: the move and the post-move game.
|
||||
// MoveResult is the outcome of a committed move: the move and the post-move game. rack and
|
||||
// bag_len carry the actor's own post-move private state — their refilled rack (alphabet indices,
|
||||
// Stage 13; a blank is the sentinel index 255) and the bag size after drawing — so the mover
|
||||
// renders the next state straight from this response without a follow-up game.state (R4; added
|
||||
// trailing — backward-compatible).
|
||||
table MoveResult {
|
||||
move:MoveRecord;
|
||||
game:GameView;
|
||||
rack:[ubyte];
|
||||
bag_len:int;
|
||||
}
|
||||
|
||||
// StateRequest asks for the requesting player's view of a game. include_alphabet asks the
|
||||
@@ -477,6 +483,8 @@ table GcgExport {
|
||||
// move kind ("play"/"pass"/"exchange"/...), last_word is the main word of a scoring play (empty
|
||||
// otherwise), and score_line is the recipient-first running score (e.g. "120:95:80"). They are
|
||||
// appended (FlatBuffers-optional), so an older reader that only needs game_id/deadline is unaffected.
|
||||
// move_count is the post-move count (matching the opponent_moved GameView): the client uses it to
|
||||
// tell whether its cached game already reflects the move, falling back to a refetch on a gap (R4).
|
||||
table YourTurnEvent {
|
||||
game_id:string;
|
||||
deadline_unix:long;
|
||||
@@ -484,25 +492,35 @@ table YourTurnEvent {
|
||||
last_action:string;
|
||||
last_word:string;
|
||||
score_line:string;
|
||||
move_count:int;
|
||||
}
|
||||
|
||||
// GameOverEvent signals that a game the recipient is seated in has finished, driving the
|
||||
// out-of-app "game over" push (Stage 17). result is the outcome from the recipient's own
|
||||
// perspective ("won"/"lost"/"draw"); score_line is the recipient-first final score.
|
||||
// perspective ("won"/"lost"/"draw"); score_line is the recipient-first final score. game is the
|
||||
// final post-game summary (adjusted scores after rack penalties + the winner flag), so the client
|
||||
// settles the finished game from the event without a refetch (R4; added trailing).
|
||||
table GameOverEvent {
|
||||
game_id:string;
|
||||
result:string;
|
||||
score_line:string;
|
||||
game:GameView;
|
||||
}
|
||||
|
||||
// OpponentMovedEvent summarises a move another seat just committed; the client
|
||||
// refetches the full state.
|
||||
// OpponentMovedEvent carries a move another seat just committed as a delta the client applies to
|
||||
// its cached game without a refetch (R4): move is the decoded play/pass/exchange (the same record
|
||||
// game.history returns), game is the post-move summary (per-seat scores, to_move, move_count,
|
||||
// status) and bag_len is the bag size after the draw. The leading seat/action/score/total scalars
|
||||
// are the pre-R4 summary, now redundant with move/game and kept only for wire back-compat.
|
||||
table OpponentMovedEvent {
|
||||
game_id:string;
|
||||
seat:int;
|
||||
action:string;
|
||||
score:int;
|
||||
total:int;
|
||||
move:MoveRecord;
|
||||
game:GameView;
|
||||
bag_len:int;
|
||||
}
|
||||
|
||||
// NudgeEvent signals that a player nudged the recipient.
|
||||
@@ -511,17 +529,27 @@ table NudgeEvent {
|
||||
from_user_id:string;
|
||||
}
|
||||
|
||||
// MatchFoundEvent signals that an auto-match pairing (or robot substitution)
|
||||
// started a game the recipient is seated in.
|
||||
// MatchFoundEvent signals that an auto-match pairing (or robot substitution) started a game the
|
||||
// recipient is seated in. state is the recipient's full initial view of the new game (empty board,
|
||||
// dealt rack), so the client navigates straight in from the event with no follow-up fetch (R4;
|
||||
// added trailing — an older reader still reads just game_id).
|
||||
table MatchFoundEvent {
|
||||
game_id:string;
|
||||
state:StateView;
|
||||
}
|
||||
|
||||
// NotificationEvent is a lightweight "something changed, re-poll" signal that
|
||||
// drives the lobby badge (incoming friend requests, invitations). kind is a sub-
|
||||
// discriminator ("friend_request", "friend_added", "friend_declined", "invitation",
|
||||
// "game_started"); the client re-fetches its lobby counters (and, for a requester
|
||||
// watching a game, its friend state) on any of them.
|
||||
// watching a game, its friend state) on any of them. To let the client update its lobby without a
|
||||
// follow-up fetch (R4), each event also carries the payload its kind changed: account for the
|
||||
// friend_* kinds (the requester/friend), invitation for "invitation" (the new invitation) and
|
||||
// state for "game_started" (the started game's initial view, like match_found). Only the field
|
||||
// matching kind is set (all added trailing — backward-compatible).
|
||||
table NotificationEvent {
|
||||
kind:string;
|
||||
account:AccountRef;
|
||||
invitation:Invitation;
|
||||
state:StateView;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user