-
-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(WebSocket): forward client messages to the server by default #545
Conversation
* This is called when the WebSocket client sends data. | ||
*/ | ||
abstract onOutgoing: WebSocketTransportOnOutgoingCallback | ||
export type WebSocketTransportEventMap = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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).
/** | ||
* Emit the "close" event on the "client" connection | ||
* whenever the underlying transport is closed. | ||
* @note "client.close()" does NOT dispatch the "close" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was not clear before. Added a better explanation.
// 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) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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. |
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.README
to reflect this change.