Migrate from socket.io to raw websocket (cloudflare durable object)#4
Open
devanhurst wants to merge 3 commits into
Open
Migrate from socket.io to raw websocket (cloudflare durable object)#4devanhurst wants to merge 3 commits into
devanhurst wants to merge 3 commits into
Conversation
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.
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.
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.