Sorry for my previous post, Brano. I did not read your answer right. You said to store a reference to the server object on heap which should work.
Thank you very much, I will check what that means for my design. Best regards, Jupp On Tuesday, July 5, 2016 at 2:04:57 PM UTC+2, [email protected] wrote: > > Hi Brano, > > thanks for the answer. > > Doesn't "kj::mv" invalidate variable "server" since its ownership is moved > to EzRpcServer? > > Best regards, > Jupp > > On Tuesday, July 5, 2016 at 1:26:11 PM UTC+2, Branislav Katreniak wrote: >> >> You can remember the reference to ServerImpl before you pass it to >> EzRpcServer. >> >> auto server = kj::heap<ServerImpl>(); >> ServerImpl& serverRef = *server; >> capnp::EzRpcServer server(kj::mv(server), ip_address, port); >> >> Kind regards >> Brano >> >> On Tue, Jul 5, 2016 at 9:12 AM, <[email protected]> wrote: >> >>> Hi David, >>> >>> thank you very much for the answer. I wasn't able to finally test it, >>> because I am now having a different problem related to my post. >>> Suppose I have the following server implementation: >>> >>> class ServerImpl:public ServerInterface::Server { >>> private: >>> std::vector<ClientInterface::Client> registered_clients_; >>> >>> public: >>> kj::Promise<void> registerClientInterface( >>> RegisterClientInterfaceContext context) override { >>> this->registered_clients_.push_back(context.getParams().getClient >>> ()); >>> } >>> >>> // ... >>> } >>> >>> class ComHandler { >>> public: >>> void Run(const std::string& ip_address, std::size_t port) { >>> capnp::EzRpcServer server(kj::heap<ServerImpl>(), ip_address, port); >>> kj::WaitScope &wait_scope = server.getWaitScope(); >>> >>> kj::NEVER_DONE.wait(wait_scope); >>> } >>> >>> void InvokeFunctionOnClient() { >>> // Here I need access to ServerImpl owned by EzRpcServer. >>> // How would I do that? >>> } >>> } >>> >>> I can only store the client capabilities in class "ServerImpl" since an >>> rvalue is needed for pushing to the vector. Since the object of >>> "ServerImpl" is owned by EzRpcServer, I do not have the possibility to >>> invoke a client's function from outside, e.g. from class "ComHandler". >>> >>> How would I do that? >>> >>> Best regards, >>> Jupp >>> >>> >>> -- 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.
