简体   繁体   中英

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. I need some kind of response.releaseSocket() after writing the last chunk. I see WebSockets has that but what about when I am using the await stuff?

thanks, Dean

ah, I think it is noticing I never called await and in that case closes the socket. If I call await, it knows to keep the socket open. That makes sense.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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