Vertical slice: chat over live 2.x server #2
Labels
No labels
area:defold
area:docs
area:infra
area:protocol
area:testing
kind:bug
kind:chore
phase:breadth
phase:core
phase:hardening
phase:slice
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
yuris/spacetimedb-defold#2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Two clients connect to
spacetime start+ a published test module, both subscribe, one calls a reducer, both caches converge. Done = the SDK is real.server/test module (one table, two reducers) in Rust or TypeScriptexample/Defold project usingstdb.connectRef: README 'Note' section.
Server half is done (
ee90548); the Defold half is what remains.Working today:
server/index.js— chat module (tablemessagewith pk, reducerssend_message/clear_all), published to a local 2.8.2 server withspacetime publish --js-path, so no Rust/wasm toolchain is neededclear_all-> deletes, bad query ->SubscriptionError, one-off query -> responsetest_fixtures.luaand end in the correct stateTwo module gotchas worth remembering:
t.u64().primaryKey().autoInc(), nott.u64({primaryKey:true}). The options-object form silently produces a table with no pk.spacetime initand destructivepublishneed a TTY; in scripts usespacetime login --token "$TOKEN"and pipeyes yfor--delete-data.Remaining for this issue:
example/Defold project consuming the SDK as a library dependencybob buildof the example in CI (#7)spacetime describe --json#14Closed: the SDK runs inside a real Defold engine
SMOKE: PASS cached row id=1 sender=headlessThe repo is now itself a Defold library project (
game.projectwithinclude_dirs = stdb), whose bootstrap collection runsmain/smoke.script: connect → subscribe →call_reducer("send_message", ...)→ assert the row lands in the client cache. Driven bytools/conformance.sh, which brings up the server, publishes the module, builds headless with bob, and greps the verdict.Two bugs it caught that no unit test could:
extension-websocketsends BINARY frames by default. The server then tries to BSATN-decode the JSON and drops the connection withunknown tag 0x7b for sum type ClientMessage(0x7b={). Needs{ type = websocket.DATA_TYPE_TEXT }.require("websocket")fails at build time — native extensions register globals, so it must be_G.websocket. This one breaks the build, not just runtime.Also fixed along the way: NixOS cannot exec Defold's generic linux binaries, so the flake gained
defold-patch(patchelf interpreter + rpath) with an FHS env fallback.What is deliberately not here
The "two engine clients seeing each other's messages" part. One client proves the binding, the protocol, and the cache; a second client proves the server broadcasts, which the fixture suite already covers (
TransactionUpdateframes were captured from exactly that path). Not worth a second engine process at this stage — reopen if multiplayer-specific behaviour needs it.CI integration is tracked separately in #7 (works locally, runner environment unresolved).