Is it possible to run Cap'n Proto RPC client and use it from another
threads to perform asynchronous RPC calls?
I've written the following client behavior, how to make the code work if
it's possible?
capnp::EzRpcClient client(argv[1], 5923);
auto& waitScope = client.getWaitScope();
Directory::Client cap = client.getMain<Directory>();
std::thread([&]() {
while(true) {
auto request = cap.openRequest();
request.setName("test");
auto promise = request.send();
promise.then([](capnp::Response<Directory::OpenResults>&& r) {
std::cout << r.getTest().cStr() << std::endl;
});
sleep(1);
}
}).detach();
kj::NEVER_DONE.wait(waitScope)
Also I didn't find any example of asynchronous responding. How to implement the
following server behavior?
class DirectoryImpl final: public Directory::Server {
public:
kj::Promise<void> open(OpenContext context) override {
asio_io_service.post([=](){
// Fetching information on another thread
capnproto_io_service.post([=](){
context.getResults().setFile("lol");
//TODO: Sending the result to the client
});
});
}
};
--
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 [email protected].
Visit this group at https://groups.google.com/group/capnproto.