Skip to content

Migrate from socket.io to raw websocket (cloudflare durable object)#4

Open
devanhurst wants to merge 3 commits into
ashbash1987:masterfrom
devanhurst:master
Open

Migrate from socket.io to raw websocket (cloudflare durable object)#4
devanhurst wants to merge 3 commits into
ashbash1987:masterfrom
devanhurst:master

Conversation

@devanhurst

Copy link
Copy Markdown

This pull request introduces two major changes: it migrates the host connection from socket.io to raw WebSocket, and it makes the server URL a fixed constant (https://hackbox.ca/) instead of a configurable field. As a result, all socket.io-related code and dependencies have been removed, and the codebase now exclusively uses native WebSocket APIs. The inspector no longer exposes the server URL, and all hosts connect to the production relay.

claude and others added 3 commits June 13, 2026 22:16
Move the Unity host package off the legacy socket.io endpoint and onto the
new Cloudflare relay, which speaks raw WebSocket with a { type, payload }
JSON envelope. The application protocol (event names + payloads) is
unchanged, so all consumer game code, State/UI/Builders, and the editor
tooling are untouched; only the transport and a few endpoints in Host.cs move.

- Host.cs: point URL at hackbox.ca, use /api/rooms for room create/lookup,
  and build the realtime URL as wss://hackbox.ca/r/<code>?userId=<hostId>.
- Replace the bundled socket.io clients with hand-rolled raw-WebSocket
  transports behind the existing ISocketIO seam: StandaloneSocket uses
  System.Net.WebSockets.ClientWebSocket; WebGLSocket drives the browser
  WebSocket via a rewritten .jslib. Both wrap/unwrap the envelope, run a
  25s keepalive ping, and reconnect with backoff (fatal closes >= 4000 are
  surfaced, not retried).
- Remove the SocketIOClient libraries and socket.io WebGL bridge, and drop
  their asmdef references. No third-party socket dependency remains.
- Bump to 0.14.0 and document the breaking change.
Replace socket.io with raw WebSocket relay transport
Remove the editable `URL` field on `Host` so users can't point a host at a
different server. It's now a `public const` (`https://hackbox.ca/`), dropped
from the inspector, with all other endpoints derived from it as before. The
editor's read-only "Server" display now reads the constant.
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