Abstract WebSocket adapter interface to support multiple libraries#38
Open
Abstract WebSocket adapter interface to support multiple libraries#38
Conversation
Co-authored-by: evangwt <3397805+evangwt@users.noreply.github.com>
Co-authored-by: evangwt <3397805+evangwt@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Abstract a WebSocket adapter interface to support multiple libraries
Abstract WebSocket adapter interface to support multiple libraries
Sep 28, 2025
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 PR introduces a WebSocket adapter interface to decouple go-vncproxy from any specific WebSocket library, enabling support for multiple WebSocket implementations while maintaining full backward compatibility.
Problem
Previously, go-vncproxy was tightly coupled to
golang.org/x/net/websocket, making it difficult for users to integrate with other popular WebSocket libraries likegithub.com/gorilla/websocketorgithub.com/coder/websocket.Solution
WebSocket Adapter Interface
Introduced two key interfaces:
Backward Compatibility
All existing code continues to work unchanged:
New Extensible API
Users can now easily integrate custom WebSocket libraries:
Custom Adapter Support
The PR includes documentation and examples for implementing custom adapters, such as for Gorilla WebSocket:
Changes Made
New files:
websocket_adapter.go: Core interface definitionsnet_websocket_adapter.go: Default adapter for golang.org/x/net/websocketwebsocket_adapter_test.go: Comprehensive test suiteexample_gorilla_adapter.go: Example adapter implementationModified files:
proxy.go: Added adapter support while preserving existing APIpeer.go: Updated to use WebSocketAdapter interfaceexample/main.go: Enhanced with usage examplesREADME.md: Comprehensive documentation with examplesBenefits
Testing
Added comprehensive tests including:
All existing tests continue to pass, ensuring no regressions.
This change significantly improves the library's flexibility and extensibility while maintaining its simplicity and backward compatibility.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.