akka/akka-http

Improved handle APIs for websockets that automatically accumulate messages etc

開放

#1,979 建立於 2018年4月6日

 (3 則留言) (0 個反應) (0 位負責人)Scala (598 個分叉)batch import
1 - triagedhelp wanted

倉庫指標

星標
 (1,311 顆星)
PR 合併指標
 (平均合併 1天 10小時) (30 天內合併 2 個 PR)

描述

This is a good idea by @jrudolph to improve handling websockets:

https://github.com/akka/akka-http/pull/611#issuecomment-275113296


I think the change does what it advertises. However, I'd like to experiment with alternative APIs, instead, before people start to use toStrict (which requires to deal with futures) when an alternative could solve the issue in a simpler way.

What I'd like to try first is adding a method to UpgradeToWebSocket:

def handleStrictMessages(Graph[FlowShape[StrictMessage, Message], Any], ...)
def handleStrictTextMessages(Graph[FlowShape[TextMessage.Strict, Message], Any], ...)
def handleStrictBinaryMessages(Graph[FlowShape[BinaryMessage.Strict, Message], Any], ...)

where StrictMessage is either a new hierarchy of WS messages or a new subtype. All of these should automatically "do the right thing", i.e. accumulating streamed messages with a configured timeout and maximum size and ignore messages of the wrong shape. We could probably reuse your toStrict logic for it. Is that something you would like to help with, @rbudzko?

貢獻者指南