Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

any plan for supporting RPC? until then what would be a good workaround? #10

Open
timotheecour opened this issue Jan 22, 2018 · 1 comment

Comments

@timotheecour
Copy link

No description provided.

@ThomasBrixLarsen
Copy link
Contributor

I'm not planning on implementing the RPC spec myself as it's not a good fit for what I'm doing with capnp.

As a workaround I usually have a union for request/response and switch on them when sending/receiving a message. I then wrap it in functions so it looks like RPC.

Something like this:

//client side
void add(int a, int b)
{
	sendPacket((ref Packet.Builder packet) {
		packet.initRequest().setAdd(a, b);
	});
}

//server side
switch(request.which())
{
	case Packet.Request.Which.Add:
	{
		sendPacket((ref Packet.Builder packet) {
			packet.initResponse().setSum(packet.request.a + packet.request.b);
		});
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants