Is it possible to get a callback when data fed into a Play Concurrent.unicast Enumerator's channel has been processed?

故事扮演 提交于 2019-12-24 11:55:02

问题


I'm proxying between a TCP connection and a WebSocket, and I want to apply back-pressure to the TCP socket if the WebSocket is sending data to the browser slowly. When I receive data from the TCP socket I do:

channel.push(data.toArray)

I'd like to get an acknowledgement of when that data has been sent. How do I get that?


回答1:


I've done this:

val resumer = Enumeratee.map[Array[Byte]] { in =>
    connection ! Tcp.ResumeReading
    in
}

val enumeratorWithAck = enumerator &> resumer

It seems to work, but is it the right way to do it?



来源:https://stackoverflow.com/questions/28041042/is-it-possible-to-get-a-callback-when-data-fed-into-a-play-concurrent-unicast-en

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!