Hi Vitaliy, The trick to loops with KJ promises is do them recursively, like:
kj::Promise<void> loop(PointStream::Client stream) { auto req = stream.nextRequest(); req.setPoint(...); return req.send().then([stream=kj::mv(stream)]() mutable { return loop(kj::mv(stream)); }); } Hope that helps! -Kenton On Thu, Apr 30, 2020 at 3:50 PM Vitaliy Ostapchuk < vitaliy.ostapchu...@gmail.com> wrote: > Hey Kenton, > > once again thanks for your help here! I already looked into the HTTP > implementation, but as you said there is too much going on around it to > clearly separate the stream code without all the wrappers and factories > around it. As you already said I have just the receiving part here and > struggling a bit to get the sender part working correctly. > > kj::Promise<void> pointStream(PointStreamContext context) > { > // get the callback provided by client > auto params = context.getParams(); > streamCallback = kj::mv(params.getCallback()); > > // call next() in a loop ?? > // call done() at the end ?? > > return kj::READY_NOW; > } > > > If someone can help me out here it would mean a lot! :) > > As for sending the data in bigger chunks, this of cause would make sense. > This code if for testing the different candidates only so it does not > matter for now. Anyway thanks for the advice of cause! > > Best regards > > -- > You received this message because you are subscribed to the Google Groups > "Cap'n Proto" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to capnproto+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/capnproto/88b39da9-c582-4976-a07c-704a21833f87%40googlegroups.com > <https://groups.google.com/d/msgid/capnproto/88b39da9-c582-4976-a07c-704a21833f87%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Cap'n Proto" group. To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/capnproto/CAJouXQ%3DonjTF0r%2BrFzBPH%3DYO2qPf4BuGQwNJmhHQMz8cy8Tviw%40mail.gmail.com.