Update C# sdk to use v3 websocket api by joshua-spacetime · Pull Request #4763 · clockworklabs/SpacetimeDB

Description of Changes

This PR adds C# SDK support for the v3.bsatn.spacetimedb WebSocket transport which was added in #4761 and keeps v2 as a fallback.

v3 is just a transport wrapper around already-encoded v2 logical messages:

  • the client offers v3 first and falls back to v2 during handshake when needed
  • when v3 is negotiated, outbound client messages are batched into a single transport frame
  • v3 batching is capped at 256 KiB per frame
  • after sending one capped v3 frame, the send pump schedules a follow-up pass using the SDK’s existing scheduling primitives rather than draining the entire queue in one uninterrupted pass
  • inbound v3 server frames are unwrapped into their inner v2 messages and then processed by the existing v2 parse/apply pipeline in order

This also includes Unity WebGL transport updates so the C# SDK can:

  • offer multiple WebSocket subprotocols
  • observe the negotiated protocol
  • switch send/receive transport behavior accordingly

API and ABI breaking changes

None. Existing servers that only support v2 continue to work because the SDK falls back during handshake.

Expected complexity level and risk

3

The main risks are:

  • preserving message ordering when multiple logical messages share one v3 frame
  • preserving fallback behavior for v2
  • keeping the capped batching behavior from starving other websocket work
  • keeping WebGL protocol negotiation and callback marshalling correct

The risk is limited by keeping the existing v2 logical message pipeline intact underneath the new transport layer.

Testing

Integration tests for v3 and v2 fallback