Added Websocket::with_message_stream
for client message customization
#501
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 adds a
Websocket::with_message_stream()
in order to allow developers to customize theClientMessage
s received by their Websocket.Specifically,
Websocket::with_message_stream()
can be used to implement file uploads over websockets as well as websocket serialization alternatives such as msgpack.** Note: At the moment a developer implementing a msgpack websockets would need to convert their serialization errors to
serde_json::error
. This is less ergonomic then ideal but it is hoped that it is workable as a first API iteration.Primary Motivation
Enable developers to explore uploading files over non-HTTP channels.
Secondary Motiviation
Allows other
ClientMessage
customizations.API Changes
Websocket::with_message_stream()
to allow developers to customize theClientMessage
creation for their websocket.ClientMessage
aspub
(for Websocket::with_message_stream)ClientMessage::from_bytes()
to keep code duplication at a minimumExample Usage
Example usage in an application: https://github.com/tegapp/teg/blob/develop/crates/server/src/main.rs