27 lines
707 B
C++
27 lines
707 B
C++
#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;
|
|
}
|