WebSockets should use standard marshallers via TextMessage
- Dominant language
- Scala
- Stars
- 1.4k
- Forks
- 584
- Avg merge
- 14h 33m
- Merged PRs (30d)
- 24
Description
**Issue by [fommil](https://github.com/fommil)**
_Sunday Jul 12, 2015 at 11:36 GMT_
_Originally opened as https://github.com/akka/akka/issues/17969_
---
When using the new `handleWebsocketMessages` it is probably pretty reasonable to expect that the same marshallers will be used here as in the REST API (and at least the user could provide an implicit `ToResponseMarshallable` in the scope). However, `handleWebsocketMessages` expects a `Flow[Message, Message, _]` which demands that users manually implement the marshalling.
This results in this level of boilerplate:
``` scala
val flow = Flow[Message].collect {
case TextMessage.Strict(msg) =>
msg.parseJson.convertTo[RpcRequestEnvelope]
// ignores everything else
}.via(Flow.wrap(sink, source)((_, _) => ())).map {
case e: RpcResponseEnvelope =>
TextMessage.Strict(e.toJson.prettyPrint): Message
}
```
Contributor guide
Research direction
Start at handleWebsocketMessages and trace its Flow[Message, Message, _] interface, then compare it with the REST API marshalling path and ToResponseMarshallable mentioned in the issue. Done means WebSocket messages can use the standard marshallers without requiring users to manually convert TextMessage values and response envelopes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- backend-api-design, networking
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100