feat(rpc): implement P2 S-RPC-01..03 Wire v1 binary codec and unary HTTP/1.1 RPC subsystem
This commit is contained in:
1 parent
691808eab6
commit
5184d1cf8c
11 files changed
+1778
-1
No files matched your search
@@ -0,0 +1,26 @@
|
||||
#include <Void/RPC/Codec.hpp>
|
||||
#include <Void/RPC/Rpc.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace Void::RPC;
|
||||
Server server;
|
||||
constexpr MethodId kPing{1, 1};
|
||||
auto reg = server.bind(
|
||||
MethodDescriptor{kPing, "sys", "ping", 1, true},
|
||||
[](const CallContext&, OwnedBytes body) { return Void::Result::ok(body); });
|
||||
if (!reg.has_value() || !server.start().has_value()) {
|
||||
return 1;
|
||||
}
|
||||
Client client{ClientOptions{.endpoint_base_url = server.base_url()}};
|
||||
OwnedBytes payload{std::byte{'o'}, std::byte{'k'}};
|
||||
auto resp = client.call(kPing, payload);
|
||||
server.shutdown();
|
||||
if (!resp.has_value() || resp->size() != 2 || (*resp)[0] != std::byte{'o'}) {
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user