working commit

This commit is contained in:
2026-04-24 16:50:15 +02:00
parent 37d9ee63cc
commit ace92da151
26 changed files with 3879 additions and 1893 deletions
+53
View File
@@ -0,0 +1,53 @@
#include <expected>
#include <string>
#include <vector>
#include <span>
#include <iostream>
#include <sstream>
#include <netclient.hpp>
#include <nethandler.hpp>
#include <fakeconnect.hpp>
#include <rpcheader.hpp>
#include <control.pb.h>
class FakeHandler : public NetHandler {
public:
std::expected<void, std::string> Handle(std::string& req, std::string& res) override;
};
std::expected<void, std::string> FakeHandler::Handle(std::string& req, std::string& res) {
control::HelloRequest pbReq;
pbReq.ParseFromString(req);
std::cout << std::format("name: {}\n", pbReq.name());
std::cout << std::format("id: {}\n", pbReq.id());
return {};
}
int main(int argc, char** argv) {
FakeHandler handler;
FakeConnector conn(handler);
control::HelloRequest pbReq;
pbReq.set_id(10);
pbReq.set_name("barefoo");
std::string rawReq;
pbReq.SerializeToString(&rawReq);
RPCHeader reqHeader(rawReq.size());
auto rawHeader = reqHeader.Encode();
std::cout << rawHeader.size() << std::endl;
std::string reqPacket;
reqPacket.append(rawHeader);
reqPacket.append(rawReq);
conn.Write(reqPacket);
std::string rawRes;
}