working commit

This commit is contained in:
2026-04-27 11:53:11 +02:00
parent 43d1cfc2b4
commit ac88dbd051
14 changed files with 281 additions and 148 deletions
+16 -18
View File
@@ -12,35 +12,33 @@
#include <rpcclient.hpp>
#include <rpcheader.hpp>
#include <netclient.hpp>
void Router(std::string& req, std::string& res) {
std::string rawResult;
control::HelloResult helloRes;
helloRes.Clear();
helloRes.set_message("foobare");
helloRes.SerializeToString(&rawResult);
res.append(rawResult);
RPCClient::RPCClient(NetClient& iconnector) {
connector = &iconnector;
}
std::expected<void, std::string> RPCClient::Transaction(const pbMessage& pbReq, pbMessage& pbRes) {
std::expected<void, std::string> RPCClient::DoTransaction(const pbMessage& pbReq, pbMessage& pbRes) {
std::string rawRequest;
pbReq.SerializeToString(&rawRequest);
//RPCHeader header(rawRequest.size());
//auto rawHeader = header.Encode();
RPCHeader reqHeader(rawRequest.size());
auto rawReqHeader = reqHeader.Encode();
std::string reqPacket;
//request.append(rawHeader);
reqPacket.append(rawReqHeader);
reqPacket.append(rawRequest);
std::string resPacket;
Router(reqPacket, resPacket);
connector->Write(reqPacket);
pbRes.ParseFromString(resPacket);
const int headerSize = 8;
std::string rawResHeader;
connector->Read(rawResHeader, headerSize);
RPCHeader resHeader;
resHeader.Decode(rawResHeader);
std::string rawResponse;
connector->Read(rawResponse, resHeader.PacketSize());
pbRes.ParseFromString(rawResponse);
return {};
}