I'm not sure I'm usign the right terminology in my question, but I hope you will understand my problem with the following example.
I'm developing a media library where the user can play/pause/stop different kinds of "pipelines" (source ~ camera, filter ~ processing, sink ~ display). Depending on their type, these pipeline can listen to each other, or not (e.g: a source pipeline cannot listen). I'm now working on a "capnp wrapper" of the library, so that it can be controlled via RPC.
I have replicated the class inheritance with success:
interface Publisher {}
interface Subscriber {
listenTo @0 (publisher :Publisher);
}
interface Pipeline {
play @0 ();
pause @1 ();
stop @2 ();
}
interface SourcePipeline extends(Pipeline, Publisher) {}
interface FilterPipeline extends(Pipeline, Publisher, Subscriber) {}
interface SinkPipeline extends(Pipeline, Subscriber) {}
Server-side I have those impl classes, which holds the references to the underlying objects of the media library (pub_ & sub_).
class PublisherImpl : public virtual GstDaemon::Publisher::Server {
protected:
PublisherImpl(my_underlying_library::Publisher* pub) : pub_(pub) {}
private:
my_underlying_library::Publisher* pub_;
};
class SubscriberImpl : public virtual GstDaemon::Subscriber::Server {
protected:
SubscriberImpl(my_underlying_library::Subscriber* sub) : sub_(sub) {}
kj::Promise<void> listenTo(ListenToContext context) override {
auto pub = context.getParams().getPublisher(); // GstDaemon::Publisher::Client
// ??? = PublisherImpl::pub_
sub_->listenTo(???) }
private:
my_underlying_library::Subscriber* sub_;
};
Now, from the client, I wanted to do something like this:
//GstDaemon::Subscriber::Client subscriber; // already returned by the server
//GstDaemon::Publisher::Client publisher; // already returned by the server
auto request = subscriber.listenToRequest();
request.setPublisher(publisher);
auto promise = request.send();
However, as you can see, on the server it's not possible to get the pub_ pointer when the listenTo method is called. Is there any way I can get a reference to the PublisherImpl here ?