当数据馈入 Play Concurrent.unicast Enumerator's 频道时,是否有可能获得回调? [英] Is it possible to get a callback when data fed into a Play Concurrent.unicast Enumerator's channel has been processed?

查看:92
本文介绍了当数据馈入 Play Concurrent.unicast Enumerator's 频道时,是否有可能获得回调?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 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 Enumerator's 频道时,是否有可能获得回调?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆