Repository navigation
Replace Socket.IO with custom WebSocket client (RemoteSlideSocket) - #2
Merged
Merged
Conversation
remote-sli.de now runs as a Cloudflare Worker and speaks JSON over a plain WebSocket instead of the Socket.IO protocol. rs-socket.js is the small client for that: it joins a session by URL (/ws/<session>?as=host), keeps a heartbeat that the server answers without waking up, reports the round trip as "latency", and reconnects with backoff unless the server rejected the connection outright (close codes 4xxx, e.g. session not found). pageController.js uses it in place of the socket.io bundle. The "init start" handshake is gone - the role and session are part of the URL, so the server answers with init success/not_found straight away - and the "_forward" wrapper is gone as well: application events are emitted under their own name and the server relays anything it does not handle itself. The connection is opened at the end of the file, once every handler is registered. The extension and the bookmarklet both load rs-socket.js ahead of this file, so the socket.io copies they carried can go. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GfhNPpQzAKM2dMhYp66gLk
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.
Summary
This PR replaces the Socket.IO dependency with a lightweight custom WebSocket client implementation called RemoteSlideSocket. The new client is designed to work across multiple environments (website, Chrome extension, bookmarklet) without requiring a module system.
Key Changes
New file: rs-socket.js - A standalone WebSocket client (~264 lines) that implements:
on,off,emit)pageController.js updates:
new RemoteSlideSocket()initevent handshake; connection is now opened directly viasocket.connect()rejectedevent to detect when another page takes over the sessionsocket.emit("_forward", {event: "...", data: {...}})to directsocket.emit("eventName", {data: {...}})latencyeventNotable Implementation Details
https://claude.ai/code/session_01GfhNPpQzAKM2dMhYp66gLk