本文介绍了处理馈入Play Concurrent.unicast枚举器通道的数据后,是否可以获取回调?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在TCP连接和WebSocket之间进行代理,并且如果WebSocket缓慢将数据发送到浏览器,我想对TCP套接字施加反压.当我从TCP套接字接收数据时,我会这样做:
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?
推荐答案
我已经做到了:
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?
这篇关于处理馈入Play Concurrent.unicast枚举器通道的数据后,是否可以获取回调?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!