简体   繁体   English

playframework 1.2.5,延续,如何关闭响应/套接字?

[英]playframework 1.2.5, continuations, how to close the response/socket?

I have some code like their example like so(untested as of yet).... 我有一些像他们的例子这样的代码(到目前为止尚未试用)。

    Promise<Object> promise = new Promise<Object>();
    response.contentType = "application/json";
    JsonStreamer streamer = new JsonStreamer(columns, promise);
    while(streamer.hasMoreData()) {
          await(promise);
          response.writeChunk(streamer.nextDataChunk());
    }

What I don't get is how do I release the socket that the client opened? 我没有得到的是如何释放客户端打开的套接字? I am streaming some very large data back in json. 我正在流回一些非常大的数据返回json。 I need some kind of response.releaseSocket() after writing the last chunk. 写完最后一个块后,我需要某种response.releaseSocket()。 I see WebSockets has that but what about when I am using the await stuff? 我看到WebSockets具有该功能,但是当我使用await时该怎么办?

thanks, Dean 谢谢,院长

ah, I think it is noticing I never called await and in that case closes the socket. 啊,我想这是我从未打电话给await的原因,在那种情况下,我关闭了套接字。 If I call await, it knows to keep the socket open. 如果我调用await,它知道保持套接字打开。 That makes sense. 那讲得通。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM