factor IPC out of server RPC
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
// Удобный шаблонный хелпер для сгенерированных прокси.
|
||||
|
||||
Reference in New Issue
Block a user