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.