working commit
This commit is contained in:
+33
-4
@@ -1,18 +1,47 @@
|
||||
|
||||
|
||||
#include <cstring>
|
||||
#include <expected>
|
||||
#include <iostream>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
|
||||
#include <google/protobuf/message.h>
|
||||
#include <control.pb.h>
|
||||
|
||||
#include <rcpclient.hpp>
|
||||
#include <rpcclient.hpp>
|
||||
#include <rpcheader.hpp>
|
||||
|
||||
//google::protobuf::Message
|
||||
|
||||
std::expected<void, std::string> Transaction(const google::protobuf::Message& m) {
|
||||
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 {};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user