factor IPC out of server RPC

This commit is contained in:
Сергей Маринкевич
2025-12-03 18:27:08 +07:00
parent 00d359a064
commit 43f67275e2
6 changed files with 130 additions and 46 deletions
+5 -11
View File
@@ -1,6 +1,7 @@
#pragma once
#include <ipc/IpcChannel.h>
#include <ipc/IpcCodec.h>
#include <rpc/RpcValue.h>
class ProxyMarshaller {
@@ -9,22 +10,15 @@ public:
// Базовый type-erased вызов: принимает вектор RpcValue и возвращает RpcValue.
RpcValue call(const std::string& method, const RpcArgs& args) {
IpcMessage msg;
// имя метода
msg.add(method);
// аргументы (PoC: только int)
for (const auto& a : args) {
msg.add(a.asInt());
}
// упаковать запрос в IpcMessage
IpcMessage msg = IpcCodec::encodeRequest(method, args);
// отправить
channel.send(msg);
// получить ответ
// получить ответ и распаковать
IpcMessage resp = channel.receive();
return RpcValue::fromInt(resp.get<int>());
return IpcCodec::decodeResponse(resp);
}
// Удобный шаблонный хелпер для сгенерированных прокси.