Repository navigation
feat: WorldResyncAsync, to ask for a fresh baseline after frames go missing - #50
Merged
Merged
Conversation
…issing asobi v0.89.0 stamps `zone`, `frame_seq` and `kf` on the world.tick payload. This SDK hands OnWorldTick the raw payload string and parses none of it, so all three already reach the game untouched - nothing was needed to expose them, and this SDK is better off than the typed ones for that reason. What was missing is the repair. Adds WorldResyncAsync(zoneX, zoneY), which asks the server to re-send one zone's complete baseline. One zone rather than the interest ring, which is nine zones at the default view radius, and the caller already knows which zone gapped because the sequence is per zone. No gap DETECTOR here, and that is a decision rather than an omission. asobi-godot got one, but its dispatcher already holds a parsed Dictionary; this one holds a string, and the only scanner available is JsonScan.ExtractField, which takes the first match in the whole document. An entity inside `updates` carrying a field named `zone`, `frame_seq` or `kf` would be read instead of the envelope's own, silently and with no way for the caller to notice. Adding a real JSON reader to support a detector costs far more than the detector is worth, and the game already parses the frame to use `updates` at all, so it is better placed to read the sequence than the SDK is. The XML doc on WorldResyncAsync explains all of that, plus the two things a caller must get right: key entities on `zone`, and adopt a `kf` frame even when its frame_seq is LOWER, because a zone restart resets the sequence while the zone's identity does not. The payload construction lives in WsFrame rather than AsobiRealtime, and that placement is the point. Tests/AsobiCore.NET compiles WsFrame.cs but NOT AsobiRealtime.cs, which references UnityEngine and cannot build outside the editor - so anything written there is invisible to CI. Putting the frame-building in WsFrame, beside WorldInputPayload where it belongs by symmetry, makes the part that can actually be wrong testable. What remains untested is a single delegating call. Formatted with the invariant culture, and tested for it: a long carries no decimal separator, but a culture that groups digits would splice a separator into the array and produce a frame the server rejects as malformed - a bug that only appears on someone else's machine. Tests: three cases covering an ordinary coordinate pair, zero and negative coordinates (zone [0,0] is a real zone and coordinates run negative either side of the origin), and de-DE culture invariance. Suite 132/132.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
asobi v0.89.0 stamps
zone,frame_seqandkfon the world.tick payload.This SDK hands OnWorldTick the raw payload string and parses none of it, so all
three already reach the game untouched - nothing was needed to expose them, and
this SDK is better off than the typed ones for that reason.
What was missing is the repair. Adds WorldResyncAsync(zoneX, zoneY), which asks
the server to re-send one zone's complete baseline. One zone rather than the
interest ring, which is nine zones at the default view radius, and the caller
already knows which zone gapped because the sequence is per zone.
No gap DETECTOR here, and that is a decision rather than an omission. asobi-godot
got one, but its dispatcher already holds a parsed Dictionary; this one holds a
string, and the only scanner available is JsonScan.ExtractField, which takes the
first match in the whole document. An entity inside
updatescarrying a fieldnamed
zone,frame_seqorkfwould be read instead of the envelope's own,silently and with no way for the caller to notice. Adding a real JSON reader to
support a detector costs far more than the detector is worth, and the game
already parses the frame to use
updatesat all, so it is better placed to readthe sequence than the SDK is. The XML doc on WorldResyncAsync explains all of
that, plus the two things a caller must get right: key entities on
zone, andadopt a
kfframe even when its frame_seq is LOWER, because a zone restartresets the sequence while the zone's identity does not.
The payload construction lives in WsFrame rather than AsobiRealtime, and that
placement is the point. Tests/AsobiCore.NET compiles WsFrame.cs but NOT
AsobiRealtime.cs, which references UnityEngine and cannot build outside the
editor - so anything written there is invisible to CI. Putting the frame-building
in WsFrame, beside WorldInputPayload where it belongs by symmetry, makes the part
that can actually be wrong testable. What remains untested is a single delegating
call.
Formatted with the invariant culture, and tested for it: a long carries no
decimal separator, but a culture that groups digits would splice a separator into
the array and produce a frame the server rejects as malformed - a bug that only
appears on someone else's machine.
Tests: three cases covering an ordinary coordinate pair, zero and negative
coordinates (zone [0,0] is a real zone and coordinates run negative either side
of the origin), and de-DE culture invariance. Suite 132/132.