interface PointStream {
# Define some point streaming interface.
next @0 (point :PointXYZI) -> stream;
# Server will call this to submit points.
done @1 ();
# Once the stream is done this will be called.
}
pointStream @0 (callback :PointStream) -> ();
# Define a function to get the point stream.
// =======================================================================================class PointStreamImpl : public Scan::PointStream::Server { // An implementation of the PointStream interface wrapping next() and done(). // We're implementing this on the client side and will pass a reference to // the server. The server will then be able to make calls back to the client.
public: PointStreamImpl() : doneCalled(false) {}
kj::Promise<void> next(NextContext context) { KJ_REQUIRE(!doneCalled, "called next() after done()"); auto point = context.getParams().getPoint();
// ... do something with the point
return kj::READY_NOW; }
kj::Promise<void> done(NextContext context) { KJ_REQUIRE(!doneCalled, "can only call done() once"); doneCalled = true; return kj::READY_NOW; }
private: bool doneCalled;};
--
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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/capnproto/543a14f3-216c-44d4-bfd6-4a6cf43f4a77%40googlegroups.com.
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;}
--
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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/capnproto/88b39da9-c582-4976-a07c-704a21833f87%40googlegroups.com.
--
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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/capnproto/3b5f451f-c542-469a-b416-76057b22760a%40googlegroups.com.
Hey Kenton,this was exactly what I tried to do, but it does not work as intended I think. At least the done() call will never be received in my experimental approaches. Especially if it contains arguments like the size of the message it might be crucial to fix this.
For your interest regarding the iterative approach its pretty simple the reverted recursion. Basically, every recursion can be broken down to the iterative approach, it is not always as nice though, here it does not even make sense. However, you could imagine chaining the requests in a loop, the results are ignored here anyway:auto it = points.begin();while (it != points.end()) {auto request = stream.nextRequest();auto point = *it;request.setPoint(...);request.send();it++;}