Hi Jupp, On Sun, Jul 3, 2016 at 12:12 PM, <jupp.tsch...@gmail.com> wrote:
> Is this the right way to implement such a use case? > Yes. :) > How is it possible to detect if a client has disconnected and how could > this be mapped to a previously stored capability? > I like to do this: interface Handle { // no methods } registerClientInterface @0 (client :ClientInterface) -> (handle :Handle); The idea is that when the client registers its callback, the server returns a `handle` object representing the registration. The client holds on to this object as long as it wants to remain registered. If the client drops the object, then the handle's destructor will be called on the server, and the server can then unregister the callback for that client. Better yet, if the client disconnects, this will also cause the handle's destructor to be called. So, using this, you can both detect disconnects and give the client a voluntary way to unregister itself all at once. BTW, also note that if you call a method on a disconnected capability, it will throw a special kind of exception. exception.getType() will return kj::Exception::Type::DISCONNECTED. -Kenton -- 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 capnproto+unsubscr...@googlegroups.com. Visit this group at https://groups.google.com/group/capnproto.