Dear Brano, David, all,
I am finally able to call remote functions, receive return values and
handle disconnection of remote clients. What I am unable to get to work is
the ability to invoke functions on registered clients with previously
registered capabilities of clients.
The below mentioned method "ComHandler::Run" is running in its own thread
to don't stall the main thread. I am trying to invoke clients functions
like this:
void ComHandler::InvokeFunctionOnClient() {
for (ClientInterface::Client &client : this->registered_clients_) {
auto request = client.InvokeFunctionOnClientRequest();
// ...
}
}
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] <javascript:>> 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.