问题
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