48 lines
1.0 KiB
C++
48 lines
1.0 KiB
C++
|
|
#include <cstring>
|
|
#include <expected>
|
|
#include <iostream>
|
|
#include <span>
|
|
#include <string>
|
|
#include <vector>
|
|
#include <sstream>
|
|
|
|
#include <google/protobuf/message.h>
|
|
#include <control.pb.h>
|
|
|
|
#include <rpcclient.hpp>
|
|
#include <rpcheader.hpp>
|
|
|
|
|
|
void Router(std::string& req, std::string& res) {
|
|
|
|
std::string rawResult;
|
|
control::HelloResult helloRes;
|
|
helloRes.Clear();
|
|
helloRes.set_name("foobare");
|
|
helloRes.set_id(12);
|
|
helloRes.SerializeToString(&rawResult);
|
|
res.append(rawResult);
|
|
|
|
}
|
|
|
|
std::expected<void, std::string> RPCClient::Transaction(const pbMessage& pbReq, pbMessage& pbRes) {
|
|
|
|
std::string rawRequest;
|
|
pbReq.SerializeToString(&rawRequest);
|
|
|
|
//RPCHeader header(rawRequest.size());
|
|
//auto rawHeader = header.Encode();
|
|
|
|
std::string reqPacket;
|
|
//request.append(rawHeader);
|
|
reqPacket.append(rawRequest);
|
|
|
|
std::string resPacket;
|
|
Router(reqPacket, resPacket);
|
|
|
|
pbRes.ParseFromString(resPacket);
|
|
|
|
return {};
|
|
}
|