On Thu, Mar 25, 2021 at 11:38 AM [email protected] <[email protected]>
wrote:

>
> Hey,
>
> Another one of these things that's probably good design but somewhat
> puzzling.
> How do I obtain a timer in my RPC server?
> I found you need to get them from the async IO provider.
> The easyrpc server has a method to get it, but then I'm stuck.
> I need to somehow pass the timer to my server implementation, but before I
> create the RPC server I can't access the IO provider, and after I created
> the RPC server my implementation got moved into a private property.
>

The EZ interfaces turn out to be problematic in a lot of ways.

I recommend skipping them and instead using kj::setupAsyncIo() and
capnp::TwoPartyClient/TwoPartyServer to set up your async and RPC
environments more explicitly. Then you'll be able to get the timer before
you construct your server object.

Also note that you can take a (non-owning) reference to your server before
you pass it off to the RPC system. You can assume the server won't be moved
or destroyed while the RPC system is active, so the reference remains valid.


> The second question is: I saw some release notes talking about a proxy not
> having to know the exact message format it's proxying, but is there
> actually a way to make a generic capnproto proxy?
>

You can take a capability received from one RPC connection and pass it over
any other RPC connection. Cap'n Proto will automatically arrange to proxy
requests in this case. In this case, only the caller and callee actually
need to know the schema for the methods being called; the proxy doesn't
need to know. So, for example, you could cast a capability to the type
`capnp::Capability::Client` (which is the base type of all `Client`
objects), then pass it around from machine to machine, and then eventually
use `client.castAs<MyInterface>()` to cast back to the object's real type
(or any superclass), and it'll work. You can make calls and they'll pass
through all the proxies to the final object, even if the proxies don't have
the schema for `MyInterface` or only have an older version.


> Similarly I saw a few mentions of HTTP and websocket stuff, but is there
> actually a way to use Capnproto over a websocket? I need none of that right
> now, but it's interesting to know what the options are.
>

Ian mentioned MessageStream. In theory it should be easy to combine that
with KJ HTTP's WebSocket implementation -- at least to the extent that
doing anything with KJ HTTP is "easy". It's like all other KJ interfaces,
weird at first but nice when you get to know it.

-Kenton


>
> Here is my project so far btw https://github.com/NyanCAD/SimServer
> Thanks for all the help so far :)
>
> Cheers,
> Pepijn
>
> --
> 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].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/capnproto/d9072ac4-2751-4e9e-91f3-a27be38da0dbn%40googlegroups.com
> <https://groups.google.com/d/msgid/capnproto/d9072ac4-2751-4e9e-91f3-a27be38da0dbn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/capnproto/CAJouXQkOGxxGPO-0iVS4izn9YuR9j1%3DgpAc%3DPt1EK2sCY9kuiw%40mail.gmail.com.

Reply via email to