Add signaling server adapter pattern for flexible WebSocket alternatives#72
Open
Saad5400 wants to merge 3 commits intoyjs:masterfrom
Open
Conversation
Introduced a flexible adapter pattern for signaling servers, allowing users to choose between different signaling mechanisms or create custom adapters. Changes: - Created SignalingAdapter base class with standard interface - Implemented DefaultSignalingAdapter maintaining existing WebSocket behavior - Implemented LaravelEchoAdapter for Laravel Echo integration - Refactored SignalingConn to use adapters via composition - Updated WebrtcProvider to accept adapter instances or URLs - Added comprehensive documentation for using and creating adapters Benefits: - Backward compatible - existing code continues to work unchanged - Users can integrate with existing real-time infrastructure (Laravel Echo, etc.) - Easy to create custom adapters for other platforms (Socket.io, Ably, etc.) - Can mix multiple adapter types for redundant signaling paths The WebRTC and P2P functionality remains unchanged - only the signaling mechanism is abstracted.
The adapter now properly handles Echo channel subscription timing by: - Tracking channel ready state with subscribed() callback - Queuing messages until subscription_succeeded event fires - Automatically flushing queued messages when channel is ready - Adding error handling for subscription failures This prevents the "Client event triggered before channel 'subscription_succeeded'" warning and ensures all signaling messages are delivered reliably.
Updated package.json exports to use modern conditional exports format with "types" condition placed first for better TypeScript resolution. Changes: - Restructured exports field to use conditional exports properly - "types" condition now comes first for TypeScript tooling - Regenerated all TypeScript declaration files with latest changes - Verified type checking with test compilation This fixes the "Could not find a declaration file" error in Vue and other TypeScript projects.
Author
|
Ok so this is an actual issue I ran into, I'm using Laravel echo (echo is the client-side sdk that follows the reverb protocol) and the current implementation has fixed connection messages and types, which aren't compatible with Laravel echo. I thought I'd try to use claude code to refactor the signaling server login into a separate "adapter" class, so that anyone can implement their own adapter with their own sdk or custom messages and types etc ... It did great (claude code) and the output is exactly that, extracted websocket logic into adapters. |
Author
|
Closes #68 |
Author
|
@dmonad I'd really appreciate it if you have some time to look into this, and if not I still appreciate your work, it's great and I'm using my own fork for now. |
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.
Introduced a flexible adapter pattern for signaling servers, allowing users to choose between different signaling mechanisms or create custom adapters.
Changes:
Benefits:
The WebRTC and P2P functionality remains unchanged - only the signaling mechanism is abstracted.