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();
// ...
request.send();
}
}
Whenever "ComHandler::InvokeFunctionOnClient" is called, the client does
not receive anything and an exception is thrown. I suppose this is because
"ComHandler::InvokeFunctionOnClient" is called from the main thread whereas
EzRpcServer's event loop is running in a different thread.
Here's the console output of the exception:
unknown file: Failure
C++ exception with description "src/kj/async.c++:227: failed: expected head
== nullptr; EventLoop destroyed with events still in the queue. Memory
leak?; head->trace() = kj::_::ChainPromiseNode
kj::_::TransformPromiseNode<kj::Promise<void>, kj::_::Void,
capnp::TwoPartyVatNetwork::OutgoingMessageImpl::send()::{lambda()#1},
kj::_::PropagateException>
kj::_::EagerPromiseNode<kj::_::Void>
Can anyone help me?
Thanks in advance and sorry - again - for the double post.
Best regards,
Jupp
On Saturday, July 9, 2016 at 11:19:44 AM UTC+2, [email protected] wrote:
>
> 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]> 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.