feat(WebSocket): forward client messages to the server by default#545
Merged
Conversation
kettanaito
commented
Apr 5, 2024
| * This is called when the WebSocket client sends data. | ||
| */ | ||
| abstract onOutgoing: WebSocketTransportOnOutgoingCallback | ||
| export type WebSocketTransportEventMap = { |
Member
Author
There was a problem hiding this comment.
This pull request also includes an internal refactoring of the WebSocketTransport:
- No longer an abstract class but an interface. Implement it to your heart's content (which, in our case, is
EventTarget). - Transport is event-based now since multiple agents can listen to the same events (incoming/outgoing).
kettanaito
commented
Apr 5, 2024
| /** | ||
| * Emit the "close" event on the "client" connection | ||
| * whenever the underlying transport is closed. | ||
| * @note "client.close()" does NOT dispatch the "close" |
Member
Author
There was a problem hiding this comment.
This was not clear before. Added a better explanation.
kettanaito
commented
Apr 5, 2024
| // to the actual server unless the outgoing message event | ||
| // has been prevented. The "outgoing" transport event it | ||
| // dispatched by the "client" connection. | ||
| this.transport.addEventListener('outgoing', (event) => { |
Member
Author
There was a problem hiding this comment.
Feature
The actual implementation for the client-to-server automatic forwarding. The client connection results in the "outgoing" transport event. We listen to it in the server connection, and decide when to forward it to the server.
Member
Author
Released: v0.27.0 🎉This has been released in v0.27.0! Make sure to always update to the latest version ( Predictable release automation by @ossjs/release. |
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.
Changes
Outgoing client messages are now forwarded to the actual server by default after
server.connect()is called. To prevent this, callevent.preventDefault()on the respective client message.Roadmap
event.preventDefault()test for the client-to-server forwarding prevention.READMEto reflect this change.