Skip to content

Json schemas#43

Merged
SyntaxNyah merged 15 commits into
masterfrom
json-schemas
May 30, 2026
Merged

Json schemas#43
SyntaxNyah merged 15 commits into
masterfrom
json-schemas

Conversation

@OmniTroid
Copy link
Copy Markdown
Collaborator

No description provided.

OmniTroid and others added 15 commits May 30, 2026 12:47
Attach `jsonSchema` fragments to the custom enum and offset fields so
toJsonSchema() emits proper `enum` / object types instead of `{}`.
Also promote `emote` from optional-with-"" to required, and check in
the generated draft-07 schemas under src/aolib/schemas/.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`MS.client` / `MS.server` was ambiguous — could read as either
"sent by" or "received by". Match the schema constants instead.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`aolib.MSPacket` becomes `aolib.MSBroadcast` (the type), `aolib.ARUPPacket`
becomes `aolib.ARUP`, etc. Asymmetric bidirectional packets keep the
Request/Broadcast qualifier so the c2s vs s2c direction stays legible.
Drops the now-unused XInput / XBroadcastInput aliases entirely.

The schema-constant values are no longer re-exported from the aolib
barrel — only as types — so the value and type can share a name
without colliding at the index.ts re-export level.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The leading slot was modeled as a `lit(0)` (treating it as a legacy
ignored marker), but servers validate it as the player_id assigned in
the ID packet — and reject mismatches. Surface it as a required field
so callers echo back the value they stored from `on.ID`.

The trailing slot was likewise a `lit("")`; expose it as an optional
char_password (default "") so locked-slot servers can be satisfied.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Some servers reject CC with an empty char_password. Send a non-empty
sentinel so the character pick lands.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The class extended EventEmitter only to forward WebSocket events into
its own on*/emit indirection — no external listeners. Wire the socket
events straight to onOpen/onClose/onMessage/onError and drop the base
class.

Reconnect was leaking: the old socket's listeners stayed live after
cleanup(), and the 5s connect watchdog captured `this` so a pending
timer from a prior attempt could close the new socket. Per-attempt
AbortController binds both listeners and the watchdog, and connect()
aborts the previous attempt before opening a new socket.

Also rename the muddy `this.serv: any` to `this.socket: WebSocket |
undefined`. Strict typing exposed onError's incorrect ErrorEvent
parameter — WebSocket fires plain Event on error — fixed.

Identity sent in ID handshake now reads from client.software /
client.version instead of hardcoded "webAO" + version import.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The Request/Broadcast convention used elsewhere doesn't read naturally
for the ID handshake — both sides ARE the identification. Name them
by the identifier instead: IDServer is "server identifies itself",
IDClient is "client identifies itself". Wire header stays "ID".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
c2s: askchaa, CH, RC, RD, RM
s2c: decryptor, SI, DONE, CHECK

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Covers every entry in c2sSchemas and s2cSchemas not already on disk.
ARUP's update_type / update_data come through as permissive `{}` —
the field-walker can't express the discriminated-array shape and we
chose not to introduce packet-level oneOf hints for it. Callers are
expected to handle ARUP's update_data heterogeneity at runtime.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
update_type now exports as integer enum [0,1,2,3], update_data as
array of (integer | string). The cross-field discriminated-union
constraint (type 0 -> numbers, types 1-3 -> strings) is left for the
caller to enforce at runtime.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Was VSJoinRequest/Broadcast etc.; the underscore-less camelCase made
the type names diverge from the wire headers (VS_JOIN, VS_LEAVE,
VS_SPEAK). Use VS_JOINRequest / VS_JOINBroadcast so every typed
packet name has the header as a literal prefix.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@SyntaxNyah SyntaxNyah merged commit 03f2eca into master May 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants