On 10/02/2017 08:45 PM, Kenton Varda wrote:
> In particular you'll want to use kj::setupAsyncIo() to get your initial
> I/O context, and then use capnp::TwoPartyServer and
> capnp::TwoPartyClient in <capnp/rpc-twoparty.h>.
With this hint, I came up with the following:
kj::AsyncIoContext asyncio = kj::setupAsyncIo();
auto& waitScope = asyncio.waitScope;
auto& ioprovider = *asyncio.provider;
auto& network = ioprovider.getNetwork();
auto addr = network.parseAddress(SOCKET_FILE).wait(waitScope);
auto listener = addr->listen();
capnp::TwoPartyServer server(kj::heap<helloworld::TestInterfaceImpl>());
auto serverPromise = server.listen(*listener);
// Run until SIGTERM
kj::UnixEventPort::captureSignal(SIGTERM);
asyncio.unixEventPort.onSignal(SIGTERM).wait(waitScope);
std::cout << "Shutting down server..." << std::endl;
Works as far as I can see, thanks! From what I understand, the server
will close the socket if the serverPromise will be destroyed?
> Honestly I should probably deprecate the EZ classes altogether and
> direct people to these interfaces instead... it's only a couple extra
> lines to set up and then you have full flexibility.
It doesn't seem to be that much more complex, but doesn't look quite as
flashy as the Example with EZ.
/Richard
--
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.