working commit
This commit is contained in:
@@ -110,7 +110,7 @@ PROGRAMS = $(noinst_PROGRAMS) $(sbin_PROGRAMS)
|
||||
am_fakeconnect_test_OBJECTS = fakeconnect_test.$(OBJEXT) \
|
||||
rpcclient.$(OBJEXT) rpcheader.$(OBJEXT) netclient.$(OBJEXT) \
|
||||
nethandler.$(OBJEXT) fakeconnect.$(OBJEXT) \
|
||||
control.pb.$(OBJEXT)
|
||||
control.pb.$(OBJEXT) logger.$(OBJEXT)
|
||||
fakeconnect_test_OBJECTS = $(am_fakeconnect_test_OBJECTS)
|
||||
fakeconnect_test_LDADD = $(LDADD)
|
||||
am_helmetd_OBJECTS = helmetd.$(OBJEXT) tunclient.$(OBJEXT) \
|
||||
@@ -381,7 +381,8 @@ fakeconnect_test_SOURCES = fakeconnect_test.cpp \
|
||||
netclient.cpp netclient.hpp \
|
||||
nethandler.cpp nethandler.hpp \
|
||||
fakeconnect.cpp fakeconnect.hpp \
|
||||
control.pb.cc control.pb.h
|
||||
control.pb.cc control.pb.h \
|
||||
logger.cpp logger.hpp
|
||||
|
||||
ASTYLE_OPTS = --indent=spaces=8 --style=java
|
||||
all: defines.h
|
||||
|
||||
+2
-1
@@ -64,7 +64,8 @@ fakeconnect_test_SOURCES = fakeconnect_test.cpp \
|
||||
netclient.cpp netclient.hpp \
|
||||
nethandler.cpp nethandler.hpp \
|
||||
fakeconnect.cpp fakeconnect.hpp \
|
||||
control.pb.cc control.pb.h
|
||||
control.pb.cc control.pb.h \
|
||||
logger.cpp logger.hpp
|
||||
|
||||
|
||||
test: fakeconnect_test
|
||||
|
||||
+3
-2
@@ -110,7 +110,7 @@ PROGRAMS = $(noinst_PROGRAMS) $(sbin_PROGRAMS)
|
||||
am_fakeconnect_test_OBJECTS = fakeconnect_test.$(OBJEXT) \
|
||||
rpcclient.$(OBJEXT) rpcheader.$(OBJEXT) netclient.$(OBJEXT) \
|
||||
nethandler.$(OBJEXT) fakeconnect.$(OBJEXT) \
|
||||
control.pb.$(OBJEXT)
|
||||
control.pb.$(OBJEXT) logger.$(OBJEXT)
|
||||
fakeconnect_test_OBJECTS = $(am_fakeconnect_test_OBJECTS)
|
||||
fakeconnect_test_LDADD = $(LDADD)
|
||||
am_helmetd_OBJECTS = helmetd.$(OBJEXT) tunclient.$(OBJEXT) \
|
||||
@@ -381,7 +381,8 @@ fakeconnect_test_SOURCES = fakeconnect_test.cpp \
|
||||
netclient.cpp netclient.hpp \
|
||||
nethandler.cpp nethandler.hpp \
|
||||
fakeconnect.cpp fakeconnect.hpp \
|
||||
control.pb.cc control.pb.h
|
||||
control.pb.cc control.pb.h \
|
||||
logger.cpp logger.hpp
|
||||
|
||||
ASTYLE_OPTS = --indent=spaces=8 --style=java
|
||||
all: defines.h
|
||||
|
||||
+64
-131
@@ -76,9 +76,8 @@ struct ResultDefaultTypeInternal {
|
||||
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ResultDefaultTypeInternal _Result_default_instance_;
|
||||
PROTOBUF_CONSTEXPR HelloRequest::HelloRequest(
|
||||
::_pbi::ConstantInitialized): _impl_{
|
||||
/*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
|
||||
/*decltype(_impl_.message_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
|
||||
, /*decltype(_impl_.meta_)*/nullptr
|
||||
, /*decltype(_impl_.id_)*/0
|
||||
, /*decltype(_impl_._cached_size_)*/{}} {}
|
||||
struct HelloRequestDefaultTypeInternal {
|
||||
PROTOBUF_CONSTEXPR HelloRequestDefaultTypeInternal()
|
||||
@@ -91,9 +90,8 @@ struct HelloRequestDefaultTypeInternal {
|
||||
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 HelloRequestDefaultTypeInternal _HelloRequest_default_instance_;
|
||||
PROTOBUF_CONSTEXPR HelloResult::HelloResult(
|
||||
::_pbi::ConstantInitialized): _impl_{
|
||||
/*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
|
||||
/*decltype(_impl_.message_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
|
||||
, /*decltype(_impl_.meta_)*/nullptr
|
||||
, /*decltype(_impl_.id_)*/0
|
||||
, /*decltype(_impl_._cached_size_)*/{}} {}
|
||||
struct HelloResultDefaultTypeInternal {
|
||||
PROTOBUF_CONSTEXPR HelloResultDefaultTypeInternal()
|
||||
@@ -146,8 +144,7 @@ const uint32_t TableStruct_control_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(
|
||||
~0u, // no _weak_field_map_
|
||||
~0u, // no _inlined_string_donated_
|
||||
PROTOBUF_FIELD_OFFSET(::control::HelloRequest, _impl_.meta_),
|
||||
PROTOBUF_FIELD_OFFSET(::control::HelloRequest, _impl_.id_),
|
||||
PROTOBUF_FIELD_OFFSET(::control::HelloRequest, _impl_.name_),
|
||||
PROTOBUF_FIELD_OFFSET(::control::HelloRequest, _impl_.message_),
|
||||
~0u, // no _has_bits_
|
||||
PROTOBUF_FIELD_OFFSET(::control::HelloResult, _internal_metadata_),
|
||||
~0u, // no _extensions_
|
||||
@@ -155,8 +152,7 @@ const uint32_t TableStruct_control_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(
|
||||
~0u, // no _weak_field_map_
|
||||
~0u, // no _inlined_string_donated_
|
||||
PROTOBUF_FIELD_OFFSET(::control::HelloResult, _impl_.meta_),
|
||||
PROTOBUF_FIELD_OFFSET(::control::HelloResult, _impl_.id_),
|
||||
PROTOBUF_FIELD_OFFSET(::control::HelloResult, _impl_.name_),
|
||||
PROTOBUF_FIELD_OFFSET(::control::HelloResult, _impl_.message_),
|
||||
};
|
||||
static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
|
||||
{ 0, -1, -1, sizeof(::control::ReqMeta)},
|
||||
@@ -164,7 +160,7 @@ static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protode
|
||||
{ 15, -1, -1, sizeof(::control::Request)},
|
||||
{ 22, -1, -1, sizeof(::control::Result)},
|
||||
{ 29, -1, -1, sizeof(::control::HelloRequest)},
|
||||
{ 38, -1, -1, sizeof(::control::HelloResult)},
|
||||
{ 37, -1, -1, sizeof(::control::HelloResult)},
|
||||
};
|
||||
|
||||
static const ::_pb::Message* const file_default_instances[] = {
|
||||
@@ -181,15 +177,14 @@ const char descriptor_table_protodef_control_2eproto[] PROTOBUF_SECTION_VARIABLE
|
||||
"pcname\030\001 \001(\t\")\n\007ResMeta\022\r\n\005error\030\001 \001(\010\022\017"
|
||||
"\n\007message\030\002 \001(\t\")\n\007Request\022\036\n\004meta\030\001 \001(\013"
|
||||
"2\020.control.ReqMeta\"(\n\006Result\022\036\n\004meta\030\001 \001"
|
||||
"(\0132\020.control.ResMeta\"H\n\014HelloRequest\022\036\n\004"
|
||||
"meta\030\001 \001(\0132\020.control.ReqMeta\022\n\n\002id\030\002 \001(\005"
|
||||
"\022\014\n\004name\030\003 \001(\t\"G\n\013HelloResult\022\036\n\004meta\030\001 "
|
||||
"\001(\0132\020.control.ResMeta\022\n\n\002id\030\002 \001(\005\022\014\n\004nam"
|
||||
"e\030\003 \001(\tb\006proto3"
|
||||
"(\0132\020.control.ResMeta\"\?\n\014HelloRequest\022\036\n\004"
|
||||
"meta\030\001 \001(\0132\020.control.ReqMeta\022\017\n\007message\030"
|
||||
"\002 \001(\t\">\n\013HelloResult\022\036\n\004meta\030\001 \001(\0132\020.con"
|
||||
"trol.ResMeta\022\017\n\007message\030\002 \001(\tb\006proto3"
|
||||
;
|
||||
static ::_pbi::once_flag descriptor_table_control_2eproto_once;
|
||||
const ::_pbi::DescriptorTable descriptor_table_control_2eproto = {
|
||||
false, false, 335, descriptor_table_protodef_control_2eproto,
|
||||
false, false, 317, descriptor_table_protodef_control_2eproto,
|
||||
"control.proto",
|
||||
&descriptor_table_control_2eproto_once, nullptr, 0, 6,
|
||||
schemas, file_default_instances, TableStruct_control_2eproto::offsets,
|
||||
@@ -1044,24 +1039,22 @@ HelloRequest::HelloRequest(const HelloRequest& from)
|
||||
: ::PROTOBUF_NAMESPACE_ID::Message() {
|
||||
HelloRequest* const _this = this; (void)_this;
|
||||
new (&_impl_) Impl_{
|
||||
decltype(_impl_.name_){}
|
||||
decltype(_impl_.message_){}
|
||||
, decltype(_impl_.meta_){nullptr}
|
||||
, decltype(_impl_.id_){}
|
||||
, /*decltype(_impl_._cached_size_)*/{}};
|
||||
|
||||
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
|
||||
_impl_.name_.InitDefault();
|
||||
_impl_.message_.InitDefault();
|
||||
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
||||
_impl_.name_.Set("", GetArenaForAllocation());
|
||||
_impl_.message_.Set("", GetArenaForAllocation());
|
||||
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
||||
if (!from._internal_name().empty()) {
|
||||
_this->_impl_.name_.Set(from._internal_name(),
|
||||
if (!from._internal_message().empty()) {
|
||||
_this->_impl_.message_.Set(from._internal_message(),
|
||||
_this->GetArenaForAllocation());
|
||||
}
|
||||
if (from._internal_has_meta()) {
|
||||
_this->_impl_.meta_ = new ::control::ReqMeta(*from._impl_.meta_);
|
||||
}
|
||||
_this->_impl_.id_ = from._impl_.id_;
|
||||
// @@protoc_insertion_point(copy_constructor:control.HelloRequest)
|
||||
}
|
||||
|
||||
@@ -1070,14 +1063,13 @@ inline void HelloRequest::SharedCtor(
|
||||
(void)arena;
|
||||
(void)is_message_owned;
|
||||
new (&_impl_) Impl_{
|
||||
decltype(_impl_.name_){}
|
||||
decltype(_impl_.message_){}
|
||||
, decltype(_impl_.meta_){nullptr}
|
||||
, decltype(_impl_.id_){0}
|
||||
, /*decltype(_impl_._cached_size_)*/{}
|
||||
};
|
||||
_impl_.name_.InitDefault();
|
||||
_impl_.message_.InitDefault();
|
||||
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
||||
_impl_.name_.Set("", GetArenaForAllocation());
|
||||
_impl_.message_.Set("", GetArenaForAllocation());
|
||||
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
||||
}
|
||||
|
||||
@@ -1092,7 +1084,7 @@ HelloRequest::~HelloRequest() {
|
||||
|
||||
inline void HelloRequest::SharedDtor() {
|
||||
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
|
||||
_impl_.name_.Destroy();
|
||||
_impl_.message_.Destroy();
|
||||
if (this != internal_default_instance()) delete _impl_.meta_;
|
||||
}
|
||||
|
||||
@@ -1106,12 +1098,11 @@ void HelloRequest::Clear() {
|
||||
// Prevent compiler warnings about cached_has_bits being unused
|
||||
(void) cached_has_bits;
|
||||
|
||||
_impl_.name_.ClearToEmpty();
|
||||
_impl_.message_.ClearToEmpty();
|
||||
if (GetArenaForAllocation() == nullptr && _impl_.meta_ != nullptr) {
|
||||
delete _impl_.meta_;
|
||||
}
|
||||
_impl_.meta_ = nullptr;
|
||||
_impl_.id_ = 0;
|
||||
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
|
||||
}
|
||||
|
||||
@@ -1129,21 +1120,13 @@ const char* HelloRequest::_InternalParse(const char* ptr, ::_pbi::ParseContext*
|
||||
} else
|
||||
goto handle_unusual;
|
||||
continue;
|
||||
// int32 id = 2;
|
||||
// string message = 2;
|
||||
case 2:
|
||||
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) {
|
||||
_impl_.id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
|
||||
CHK_(ptr);
|
||||
} else
|
||||
goto handle_unusual;
|
||||
continue;
|
||||
// string name = 3;
|
||||
case 3:
|
||||
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) {
|
||||
auto str = _internal_mutable_name();
|
||||
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
|
||||
auto str = _internal_mutable_message();
|
||||
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
|
||||
CHK_(ptr);
|
||||
CHK_(::_pbi::VerifyUTF8(str, "control.HelloRequest.name"));
|
||||
CHK_(::_pbi::VerifyUTF8(str, "control.HelloRequest.message"));
|
||||
} else
|
||||
goto handle_unusual;
|
||||
continue;
|
||||
@@ -1183,20 +1166,14 @@ uint8_t* HelloRequest::_InternalSerialize(
|
||||
_Internal::meta(this).GetCachedSize(), target, stream);
|
||||
}
|
||||
|
||||
// int32 id = 2;
|
||||
if (this->_internal_id() != 0) {
|
||||
target = stream->EnsureSpace(target);
|
||||
target = ::_pbi::WireFormatLite::WriteInt32ToArray(2, this->_internal_id(), target);
|
||||
}
|
||||
|
||||
// string name = 3;
|
||||
if (!this->_internal_name().empty()) {
|
||||
// string message = 2;
|
||||
if (!this->_internal_message().empty()) {
|
||||
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
|
||||
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
|
||||
this->_internal_message().data(), static_cast<int>(this->_internal_message().length()),
|
||||
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
|
||||
"control.HelloRequest.name");
|
||||
"control.HelloRequest.message");
|
||||
target = stream->WriteStringMaybeAliased(
|
||||
3, this->_internal_name(), target);
|
||||
2, this->_internal_message(), target);
|
||||
}
|
||||
|
||||
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
|
||||
@@ -1215,11 +1192,11 @@ size_t HelloRequest::ByteSizeLong() const {
|
||||
// Prevent compiler warnings about cached_has_bits being unused
|
||||
(void) cached_has_bits;
|
||||
|
||||
// string name = 3;
|
||||
if (!this->_internal_name().empty()) {
|
||||
// string message = 2;
|
||||
if (!this->_internal_message().empty()) {
|
||||
total_size += 1 +
|
||||
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
|
||||
this->_internal_name());
|
||||
this->_internal_message());
|
||||
}
|
||||
|
||||
// .control.ReqMeta meta = 1;
|
||||
@@ -1229,11 +1206,6 @@ size_t HelloRequest::ByteSizeLong() const {
|
||||
*_impl_.meta_);
|
||||
}
|
||||
|
||||
// int32 id = 2;
|
||||
if (this->_internal_id() != 0) {
|
||||
total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_id());
|
||||
}
|
||||
|
||||
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
|
||||
}
|
||||
|
||||
@@ -1252,16 +1224,13 @@ void HelloRequest::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::P
|
||||
uint32_t cached_has_bits = 0;
|
||||
(void) cached_has_bits;
|
||||
|
||||
if (!from._internal_name().empty()) {
|
||||
_this->_internal_set_name(from._internal_name());
|
||||
if (!from._internal_message().empty()) {
|
||||
_this->_internal_set_message(from._internal_message());
|
||||
}
|
||||
if (from._internal_has_meta()) {
|
||||
_this->_internal_mutable_meta()->::control::ReqMeta::MergeFrom(
|
||||
from._internal_meta());
|
||||
}
|
||||
if (from._internal_id() != 0) {
|
||||
_this->_internal_set_id(from._internal_id());
|
||||
}
|
||||
_this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
|
||||
}
|
||||
|
||||
@@ -1282,15 +1251,10 @@ void HelloRequest::InternalSwap(HelloRequest* other) {
|
||||
auto* rhs_arena = other->GetArenaForAllocation();
|
||||
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
|
||||
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
|
||||
&_impl_.name_, lhs_arena,
|
||||
&other->_impl_.name_, rhs_arena
|
||||
&_impl_.message_, lhs_arena,
|
||||
&other->_impl_.message_, rhs_arena
|
||||
);
|
||||
::PROTOBUF_NAMESPACE_ID::internal::memswap<
|
||||
PROTOBUF_FIELD_OFFSET(HelloRequest, _impl_.id_)
|
||||
+ sizeof(HelloRequest::_impl_.id_)
|
||||
- PROTOBUF_FIELD_OFFSET(HelloRequest, _impl_.meta_)>(
|
||||
reinterpret_cast<char*>(&_impl_.meta_),
|
||||
reinterpret_cast<char*>(&other->_impl_.meta_));
|
||||
swap(_impl_.meta_, other->_impl_.meta_);
|
||||
}
|
||||
|
||||
::PROTOBUF_NAMESPACE_ID::Metadata HelloRequest::GetMetadata() const {
|
||||
@@ -1320,24 +1284,22 @@ HelloResult::HelloResult(const HelloResult& from)
|
||||
: ::PROTOBUF_NAMESPACE_ID::Message() {
|
||||
HelloResult* const _this = this; (void)_this;
|
||||
new (&_impl_) Impl_{
|
||||
decltype(_impl_.name_){}
|
||||
decltype(_impl_.message_){}
|
||||
, decltype(_impl_.meta_){nullptr}
|
||||
, decltype(_impl_.id_){}
|
||||
, /*decltype(_impl_._cached_size_)*/{}};
|
||||
|
||||
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
|
||||
_impl_.name_.InitDefault();
|
||||
_impl_.message_.InitDefault();
|
||||
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
||||
_impl_.name_.Set("", GetArenaForAllocation());
|
||||
_impl_.message_.Set("", GetArenaForAllocation());
|
||||
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
||||
if (!from._internal_name().empty()) {
|
||||
_this->_impl_.name_.Set(from._internal_name(),
|
||||
if (!from._internal_message().empty()) {
|
||||
_this->_impl_.message_.Set(from._internal_message(),
|
||||
_this->GetArenaForAllocation());
|
||||
}
|
||||
if (from._internal_has_meta()) {
|
||||
_this->_impl_.meta_ = new ::control::ResMeta(*from._impl_.meta_);
|
||||
}
|
||||
_this->_impl_.id_ = from._impl_.id_;
|
||||
// @@protoc_insertion_point(copy_constructor:control.HelloResult)
|
||||
}
|
||||
|
||||
@@ -1346,14 +1308,13 @@ inline void HelloResult::SharedCtor(
|
||||
(void)arena;
|
||||
(void)is_message_owned;
|
||||
new (&_impl_) Impl_{
|
||||
decltype(_impl_.name_){}
|
||||
decltype(_impl_.message_){}
|
||||
, decltype(_impl_.meta_){nullptr}
|
||||
, decltype(_impl_.id_){0}
|
||||
, /*decltype(_impl_._cached_size_)*/{}
|
||||
};
|
||||
_impl_.name_.InitDefault();
|
||||
_impl_.message_.InitDefault();
|
||||
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
||||
_impl_.name_.Set("", GetArenaForAllocation());
|
||||
_impl_.message_.Set("", GetArenaForAllocation());
|
||||
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
||||
}
|
||||
|
||||
@@ -1368,7 +1329,7 @@ HelloResult::~HelloResult() {
|
||||
|
||||
inline void HelloResult::SharedDtor() {
|
||||
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
|
||||
_impl_.name_.Destroy();
|
||||
_impl_.message_.Destroy();
|
||||
if (this != internal_default_instance()) delete _impl_.meta_;
|
||||
}
|
||||
|
||||
@@ -1382,12 +1343,11 @@ void HelloResult::Clear() {
|
||||
// Prevent compiler warnings about cached_has_bits being unused
|
||||
(void) cached_has_bits;
|
||||
|
||||
_impl_.name_.ClearToEmpty();
|
||||
_impl_.message_.ClearToEmpty();
|
||||
if (GetArenaForAllocation() == nullptr && _impl_.meta_ != nullptr) {
|
||||
delete _impl_.meta_;
|
||||
}
|
||||
_impl_.meta_ = nullptr;
|
||||
_impl_.id_ = 0;
|
||||
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
|
||||
}
|
||||
|
||||
@@ -1405,21 +1365,13 @@ const char* HelloResult::_InternalParse(const char* ptr, ::_pbi::ParseContext* c
|
||||
} else
|
||||
goto handle_unusual;
|
||||
continue;
|
||||
// int32 id = 2;
|
||||
// string message = 2;
|
||||
case 2:
|
||||
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) {
|
||||
_impl_.id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
|
||||
CHK_(ptr);
|
||||
} else
|
||||
goto handle_unusual;
|
||||
continue;
|
||||
// string name = 3;
|
||||
case 3:
|
||||
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) {
|
||||
auto str = _internal_mutable_name();
|
||||
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
|
||||
auto str = _internal_mutable_message();
|
||||
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
|
||||
CHK_(ptr);
|
||||
CHK_(::_pbi::VerifyUTF8(str, "control.HelloResult.name"));
|
||||
CHK_(::_pbi::VerifyUTF8(str, "control.HelloResult.message"));
|
||||
} else
|
||||
goto handle_unusual;
|
||||
continue;
|
||||
@@ -1459,20 +1411,14 @@ uint8_t* HelloResult::_InternalSerialize(
|
||||
_Internal::meta(this).GetCachedSize(), target, stream);
|
||||
}
|
||||
|
||||
// int32 id = 2;
|
||||
if (this->_internal_id() != 0) {
|
||||
target = stream->EnsureSpace(target);
|
||||
target = ::_pbi::WireFormatLite::WriteInt32ToArray(2, this->_internal_id(), target);
|
||||
}
|
||||
|
||||
// string name = 3;
|
||||
if (!this->_internal_name().empty()) {
|
||||
// string message = 2;
|
||||
if (!this->_internal_message().empty()) {
|
||||
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
|
||||
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
|
||||
this->_internal_message().data(), static_cast<int>(this->_internal_message().length()),
|
||||
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
|
||||
"control.HelloResult.name");
|
||||
"control.HelloResult.message");
|
||||
target = stream->WriteStringMaybeAliased(
|
||||
3, this->_internal_name(), target);
|
||||
2, this->_internal_message(), target);
|
||||
}
|
||||
|
||||
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
|
||||
@@ -1491,11 +1437,11 @@ size_t HelloResult::ByteSizeLong() const {
|
||||
// Prevent compiler warnings about cached_has_bits being unused
|
||||
(void) cached_has_bits;
|
||||
|
||||
// string name = 3;
|
||||
if (!this->_internal_name().empty()) {
|
||||
// string message = 2;
|
||||
if (!this->_internal_message().empty()) {
|
||||
total_size += 1 +
|
||||
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
|
||||
this->_internal_name());
|
||||
this->_internal_message());
|
||||
}
|
||||
|
||||
// .control.ResMeta meta = 1;
|
||||
@@ -1505,11 +1451,6 @@ size_t HelloResult::ByteSizeLong() const {
|
||||
*_impl_.meta_);
|
||||
}
|
||||
|
||||
// int32 id = 2;
|
||||
if (this->_internal_id() != 0) {
|
||||
total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_id());
|
||||
}
|
||||
|
||||
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
|
||||
}
|
||||
|
||||
@@ -1528,16 +1469,13 @@ void HelloResult::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PR
|
||||
uint32_t cached_has_bits = 0;
|
||||
(void) cached_has_bits;
|
||||
|
||||
if (!from._internal_name().empty()) {
|
||||
_this->_internal_set_name(from._internal_name());
|
||||
if (!from._internal_message().empty()) {
|
||||
_this->_internal_set_message(from._internal_message());
|
||||
}
|
||||
if (from._internal_has_meta()) {
|
||||
_this->_internal_mutable_meta()->::control::ResMeta::MergeFrom(
|
||||
from._internal_meta());
|
||||
}
|
||||
if (from._internal_id() != 0) {
|
||||
_this->_internal_set_id(from._internal_id());
|
||||
}
|
||||
_this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
|
||||
}
|
||||
|
||||
@@ -1558,15 +1496,10 @@ void HelloResult::InternalSwap(HelloResult* other) {
|
||||
auto* rhs_arena = other->GetArenaForAllocation();
|
||||
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
|
||||
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
|
||||
&_impl_.name_, lhs_arena,
|
||||
&other->_impl_.name_, rhs_arena
|
||||
&_impl_.message_, lhs_arena,
|
||||
&other->_impl_.message_, rhs_arena
|
||||
);
|
||||
::PROTOBUF_NAMESPACE_ID::internal::memswap<
|
||||
PROTOBUF_FIELD_OFFSET(HelloResult, _impl_.id_)
|
||||
+ sizeof(HelloResult::_impl_.id_)
|
||||
- PROTOBUF_FIELD_OFFSET(HelloResult, _impl_.meta_)>(
|
||||
reinterpret_cast<char*>(&_impl_.meta_),
|
||||
reinterpret_cast<char*>(&other->_impl_.meta_));
|
||||
swap(_impl_.meta_, other->_impl_.meta_);
|
||||
}
|
||||
|
||||
::PROTOBUF_NAMESPACE_ID::Metadata HelloResult::GetMetadata() const {
|
||||
|
||||
+78
-140
@@ -828,22 +828,21 @@ class HelloRequest final :
|
||||
// accessors -------------------------------------------------------
|
||||
|
||||
enum : int {
|
||||
kNameFieldNumber = 3,
|
||||
kMessageFieldNumber = 2,
|
||||
kMetaFieldNumber = 1,
|
||||
kIdFieldNumber = 2,
|
||||
};
|
||||
// string name = 3;
|
||||
void clear_name();
|
||||
const std::string& name() const;
|
||||
// string message = 2;
|
||||
void clear_message();
|
||||
const std::string& message() const;
|
||||
template <typename ArgT0 = const std::string&, typename... ArgT>
|
||||
void set_name(ArgT0&& arg0, ArgT... args);
|
||||
std::string* mutable_name();
|
||||
PROTOBUF_NODISCARD std::string* release_name();
|
||||
void set_allocated_name(std::string* name);
|
||||
void set_message(ArgT0&& arg0, ArgT... args);
|
||||
std::string* mutable_message();
|
||||
PROTOBUF_NODISCARD std::string* release_message();
|
||||
void set_allocated_message(std::string* message);
|
||||
private:
|
||||
const std::string& _internal_name() const;
|
||||
inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value);
|
||||
std::string* _internal_mutable_name();
|
||||
const std::string& _internal_message() const;
|
||||
inline PROTOBUF_ALWAYS_INLINE void _internal_set_message(const std::string& value);
|
||||
std::string* _internal_mutable_message();
|
||||
public:
|
||||
|
||||
// .control.ReqMeta meta = 1;
|
||||
@@ -864,15 +863,6 @@ class HelloRequest final :
|
||||
::control::ReqMeta* meta);
|
||||
::control::ReqMeta* unsafe_arena_release_meta();
|
||||
|
||||
// int32 id = 2;
|
||||
void clear_id();
|
||||
int32_t id() const;
|
||||
void set_id(int32_t value);
|
||||
private:
|
||||
int32_t _internal_id() const;
|
||||
void _internal_set_id(int32_t value);
|
||||
public:
|
||||
|
||||
// @@protoc_insertion_point(class_scope:control.HelloRequest)
|
||||
private:
|
||||
class _Internal;
|
||||
@@ -881,9 +871,8 @@ class HelloRequest final :
|
||||
typedef void InternalArenaConstructable_;
|
||||
typedef void DestructorSkippable_;
|
||||
struct Impl_ {
|
||||
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_;
|
||||
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr message_;
|
||||
::control::ReqMeta* meta_;
|
||||
int32_t id_;
|
||||
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
|
||||
};
|
||||
union { Impl_ _impl_; };
|
||||
@@ -1012,22 +1001,21 @@ class HelloResult final :
|
||||
// accessors -------------------------------------------------------
|
||||
|
||||
enum : int {
|
||||
kNameFieldNumber = 3,
|
||||
kMessageFieldNumber = 2,
|
||||
kMetaFieldNumber = 1,
|
||||
kIdFieldNumber = 2,
|
||||
};
|
||||
// string name = 3;
|
||||
void clear_name();
|
||||
const std::string& name() const;
|
||||
// string message = 2;
|
||||
void clear_message();
|
||||
const std::string& message() const;
|
||||
template <typename ArgT0 = const std::string&, typename... ArgT>
|
||||
void set_name(ArgT0&& arg0, ArgT... args);
|
||||
std::string* mutable_name();
|
||||
PROTOBUF_NODISCARD std::string* release_name();
|
||||
void set_allocated_name(std::string* name);
|
||||
void set_message(ArgT0&& arg0, ArgT... args);
|
||||
std::string* mutable_message();
|
||||
PROTOBUF_NODISCARD std::string* release_message();
|
||||
void set_allocated_message(std::string* message);
|
||||
private:
|
||||
const std::string& _internal_name() const;
|
||||
inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value);
|
||||
std::string* _internal_mutable_name();
|
||||
const std::string& _internal_message() const;
|
||||
inline PROTOBUF_ALWAYS_INLINE void _internal_set_message(const std::string& value);
|
||||
std::string* _internal_mutable_message();
|
||||
public:
|
||||
|
||||
// .control.ResMeta meta = 1;
|
||||
@@ -1048,15 +1036,6 @@ class HelloResult final :
|
||||
::control::ResMeta* meta);
|
||||
::control::ResMeta* unsafe_arena_release_meta();
|
||||
|
||||
// int32 id = 2;
|
||||
void clear_id();
|
||||
int32_t id() const;
|
||||
void set_id(int32_t value);
|
||||
private:
|
||||
int32_t _internal_id() const;
|
||||
void _internal_set_id(int32_t value);
|
||||
public:
|
||||
|
||||
// @@protoc_insertion_point(class_scope:control.HelloResult)
|
||||
private:
|
||||
class _Internal;
|
||||
@@ -1065,9 +1044,8 @@ class HelloResult final :
|
||||
typedef void InternalArenaConstructable_;
|
||||
typedef void DestructorSkippable_;
|
||||
struct Impl_ {
|
||||
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_;
|
||||
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr message_;
|
||||
::control::ResMeta* meta_;
|
||||
int32_t id_;
|
||||
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
|
||||
};
|
||||
union { Impl_ _impl_; };
|
||||
@@ -1490,74 +1468,54 @@ inline void HelloRequest::set_allocated_meta(::control::ReqMeta* meta) {
|
||||
// @@protoc_insertion_point(field_set_allocated:control.HelloRequest.meta)
|
||||
}
|
||||
|
||||
// int32 id = 2;
|
||||
inline void HelloRequest::clear_id() {
|
||||
_impl_.id_ = 0;
|
||||
// string message = 2;
|
||||
inline void HelloRequest::clear_message() {
|
||||
_impl_.message_.ClearToEmpty();
|
||||
}
|
||||
inline int32_t HelloRequest::_internal_id() const {
|
||||
return _impl_.id_;
|
||||
}
|
||||
inline int32_t HelloRequest::id() const {
|
||||
// @@protoc_insertion_point(field_get:control.HelloRequest.id)
|
||||
return _internal_id();
|
||||
}
|
||||
inline void HelloRequest::_internal_set_id(int32_t value) {
|
||||
|
||||
_impl_.id_ = value;
|
||||
}
|
||||
inline void HelloRequest::set_id(int32_t value) {
|
||||
_internal_set_id(value);
|
||||
// @@protoc_insertion_point(field_set:control.HelloRequest.id)
|
||||
}
|
||||
|
||||
// string name = 3;
|
||||
inline void HelloRequest::clear_name() {
|
||||
_impl_.name_.ClearToEmpty();
|
||||
}
|
||||
inline const std::string& HelloRequest::name() const {
|
||||
// @@protoc_insertion_point(field_get:control.HelloRequest.name)
|
||||
return _internal_name();
|
||||
inline const std::string& HelloRequest::message() const {
|
||||
// @@protoc_insertion_point(field_get:control.HelloRequest.message)
|
||||
return _internal_message();
|
||||
}
|
||||
template <typename ArgT0, typename... ArgT>
|
||||
inline PROTOBUF_ALWAYS_INLINE
|
||||
void HelloRequest::set_name(ArgT0&& arg0, ArgT... args) {
|
||||
void HelloRequest::set_message(ArgT0&& arg0, ArgT... args) {
|
||||
|
||||
_impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
|
||||
// @@protoc_insertion_point(field_set:control.HelloRequest.name)
|
||||
_impl_.message_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
|
||||
// @@protoc_insertion_point(field_set:control.HelloRequest.message)
|
||||
}
|
||||
inline std::string* HelloRequest::mutable_name() {
|
||||
std::string* _s = _internal_mutable_name();
|
||||
// @@protoc_insertion_point(field_mutable:control.HelloRequest.name)
|
||||
inline std::string* HelloRequest::mutable_message() {
|
||||
std::string* _s = _internal_mutable_message();
|
||||
// @@protoc_insertion_point(field_mutable:control.HelloRequest.message)
|
||||
return _s;
|
||||
}
|
||||
inline const std::string& HelloRequest::_internal_name() const {
|
||||
return _impl_.name_.Get();
|
||||
inline const std::string& HelloRequest::_internal_message() const {
|
||||
return _impl_.message_.Get();
|
||||
}
|
||||
inline void HelloRequest::_internal_set_name(const std::string& value) {
|
||||
inline void HelloRequest::_internal_set_message(const std::string& value) {
|
||||
|
||||
_impl_.name_.Set(value, GetArenaForAllocation());
|
||||
_impl_.message_.Set(value, GetArenaForAllocation());
|
||||
}
|
||||
inline std::string* HelloRequest::_internal_mutable_name() {
|
||||
inline std::string* HelloRequest::_internal_mutable_message() {
|
||||
|
||||
return _impl_.name_.Mutable(GetArenaForAllocation());
|
||||
return _impl_.message_.Mutable(GetArenaForAllocation());
|
||||
}
|
||||
inline std::string* HelloRequest::release_name() {
|
||||
// @@protoc_insertion_point(field_release:control.HelloRequest.name)
|
||||
return _impl_.name_.Release();
|
||||
inline std::string* HelloRequest::release_message() {
|
||||
// @@protoc_insertion_point(field_release:control.HelloRequest.message)
|
||||
return _impl_.message_.Release();
|
||||
}
|
||||
inline void HelloRequest::set_allocated_name(std::string* name) {
|
||||
if (name != nullptr) {
|
||||
inline void HelloRequest::set_allocated_message(std::string* message) {
|
||||
if (message != nullptr) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
_impl_.name_.SetAllocated(name, GetArenaForAllocation());
|
||||
_impl_.message_.SetAllocated(message, GetArenaForAllocation());
|
||||
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
||||
if (_impl_.name_.IsDefault()) {
|
||||
_impl_.name_.Set("", GetArenaForAllocation());
|
||||
if (_impl_.message_.IsDefault()) {
|
||||
_impl_.message_.Set("", GetArenaForAllocation());
|
||||
}
|
||||
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
||||
// @@protoc_insertion_point(field_set_allocated:control.HelloRequest.name)
|
||||
// @@protoc_insertion_point(field_set_allocated:control.HelloRequest.message)
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
@@ -1654,74 +1612,54 @@ inline void HelloResult::set_allocated_meta(::control::ResMeta* meta) {
|
||||
// @@protoc_insertion_point(field_set_allocated:control.HelloResult.meta)
|
||||
}
|
||||
|
||||
// int32 id = 2;
|
||||
inline void HelloResult::clear_id() {
|
||||
_impl_.id_ = 0;
|
||||
// string message = 2;
|
||||
inline void HelloResult::clear_message() {
|
||||
_impl_.message_.ClearToEmpty();
|
||||
}
|
||||
inline int32_t HelloResult::_internal_id() const {
|
||||
return _impl_.id_;
|
||||
}
|
||||
inline int32_t HelloResult::id() const {
|
||||
// @@protoc_insertion_point(field_get:control.HelloResult.id)
|
||||
return _internal_id();
|
||||
}
|
||||
inline void HelloResult::_internal_set_id(int32_t value) {
|
||||
|
||||
_impl_.id_ = value;
|
||||
}
|
||||
inline void HelloResult::set_id(int32_t value) {
|
||||
_internal_set_id(value);
|
||||
// @@protoc_insertion_point(field_set:control.HelloResult.id)
|
||||
}
|
||||
|
||||
// string name = 3;
|
||||
inline void HelloResult::clear_name() {
|
||||
_impl_.name_.ClearToEmpty();
|
||||
}
|
||||
inline const std::string& HelloResult::name() const {
|
||||
// @@protoc_insertion_point(field_get:control.HelloResult.name)
|
||||
return _internal_name();
|
||||
inline const std::string& HelloResult::message() const {
|
||||
// @@protoc_insertion_point(field_get:control.HelloResult.message)
|
||||
return _internal_message();
|
||||
}
|
||||
template <typename ArgT0, typename... ArgT>
|
||||
inline PROTOBUF_ALWAYS_INLINE
|
||||
void HelloResult::set_name(ArgT0&& arg0, ArgT... args) {
|
||||
void HelloResult::set_message(ArgT0&& arg0, ArgT... args) {
|
||||
|
||||
_impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
|
||||
// @@protoc_insertion_point(field_set:control.HelloResult.name)
|
||||
_impl_.message_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
|
||||
// @@protoc_insertion_point(field_set:control.HelloResult.message)
|
||||
}
|
||||
inline std::string* HelloResult::mutable_name() {
|
||||
std::string* _s = _internal_mutable_name();
|
||||
// @@protoc_insertion_point(field_mutable:control.HelloResult.name)
|
||||
inline std::string* HelloResult::mutable_message() {
|
||||
std::string* _s = _internal_mutable_message();
|
||||
// @@protoc_insertion_point(field_mutable:control.HelloResult.message)
|
||||
return _s;
|
||||
}
|
||||
inline const std::string& HelloResult::_internal_name() const {
|
||||
return _impl_.name_.Get();
|
||||
inline const std::string& HelloResult::_internal_message() const {
|
||||
return _impl_.message_.Get();
|
||||
}
|
||||
inline void HelloResult::_internal_set_name(const std::string& value) {
|
||||
inline void HelloResult::_internal_set_message(const std::string& value) {
|
||||
|
||||
_impl_.name_.Set(value, GetArenaForAllocation());
|
||||
_impl_.message_.Set(value, GetArenaForAllocation());
|
||||
}
|
||||
inline std::string* HelloResult::_internal_mutable_name() {
|
||||
inline std::string* HelloResult::_internal_mutable_message() {
|
||||
|
||||
return _impl_.name_.Mutable(GetArenaForAllocation());
|
||||
return _impl_.message_.Mutable(GetArenaForAllocation());
|
||||
}
|
||||
inline std::string* HelloResult::release_name() {
|
||||
// @@protoc_insertion_point(field_release:control.HelloResult.name)
|
||||
return _impl_.name_.Release();
|
||||
inline std::string* HelloResult::release_message() {
|
||||
// @@protoc_insertion_point(field_release:control.HelloResult.message)
|
||||
return _impl_.message_.Release();
|
||||
}
|
||||
inline void HelloResult::set_allocated_name(std::string* name) {
|
||||
if (name != nullptr) {
|
||||
inline void HelloResult::set_allocated_message(std::string* message) {
|
||||
if (message != nullptr) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
_impl_.name_.SetAllocated(name, GetArenaForAllocation());
|
||||
_impl_.message_.SetAllocated(message, GetArenaForAllocation());
|
||||
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
||||
if (_impl_.name_.IsDefault()) {
|
||||
_impl_.name_.Set("", GetArenaForAllocation());
|
||||
if (_impl_.message_.IsDefault()) {
|
||||
_impl_.message_.Set("", GetArenaForAllocation());
|
||||
}
|
||||
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
||||
// @@protoc_insertion_point(field_set_allocated:control.HelloResult.name)
|
||||
// @@protoc_insertion_point(field_set_allocated:control.HelloResult.message)
|
||||
}
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
+2
-4
@@ -23,14 +23,12 @@ message Result {
|
||||
|
||||
message HelloRequest {
|
||||
ReqMeta meta = 1;
|
||||
int32 id = 2;
|
||||
string name = 3;
|
||||
string message = 2;
|
||||
}
|
||||
|
||||
message HelloResult {
|
||||
ResMeta meta = 1;
|
||||
int32 id = 2;
|
||||
string name = 3;
|
||||
string message = 2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+6
-4
@@ -41,13 +41,15 @@ std::expected<int, std::string> FakeConnector::Write(std::string reqNetPacket) {
|
||||
resNetPacket.append(resHeader.Encode());
|
||||
resNetPacket.append(resData);
|
||||
|
||||
in = resNetPacket;
|
||||
backss << resNetPacket;
|
||||
auto size = backss.tellp();
|
||||
return reqNetPacket.size();
|
||||
}
|
||||
|
||||
std::expected<int, std::string> FakeConnector::Read(std::string& res, int size) {
|
||||
res = in;
|
||||
return 0;
|
||||
std::expected<int, std::string> FakeConnector::Read(std::string& resData, int size) {
|
||||
resData.resize(size);
|
||||
auto r = backss.readsome(resData.data(), size);
|
||||
return r;
|
||||
}
|
||||
|
||||
FakeConnector::~FakeConnector() {}
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
class FakeConnector : public NetClient {
|
||||
private:
|
||||
NetHandler* handler;
|
||||
std::string in;
|
||||
std::stringstream backss;
|
||||
public:
|
||||
FakeConnector(NetHandler& hand);
|
||||
std::expected<int, std::string> Write(std::string payload) override;
|
||||
|
||||
+30
-9
@@ -10,6 +10,7 @@
|
||||
#include <nethandler.hpp>
|
||||
#include <fakeconnect.hpp>
|
||||
#include <rpcheader.hpp>
|
||||
#include <logger.hpp>
|
||||
|
||||
#include <control.pb.h>
|
||||
|
||||
@@ -18,11 +19,17 @@ 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) {
|
||||
std::expected<void, std::string> FakeHandler::Handle(std::string& rawReq, std::string& rawRes) {
|
||||
control::HelloRequest pbReq;
|
||||
pbReq.ParseFromString(req);
|
||||
std::cout << std::format("name: {}\n", pbReq.name());
|
||||
std::cout << std::format("id: {}\n", pbReq.id());
|
||||
pbReq.ParseFromString(rawReq);
|
||||
std::cout << std::format("rpcName: {}\n", pbReq.meta().rpcname());
|
||||
std::cout << std::format("req message: {}\n", pbReq.message());
|
||||
|
||||
control::HelloResult pbRes;
|
||||
pbRes.set_message("Johnny!");
|
||||
auto resMeta = pbRes.mutable_meta();
|
||||
resMeta->set_error(false);
|
||||
pbRes.SerializeToString(&rawRes);
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -32,8 +39,9 @@ int main(int argc, char** argv) {
|
||||
FakeConnector conn(handler);
|
||||
|
||||
control::HelloRequest pbReq;
|
||||
pbReq.set_id(10);
|
||||
pbReq.set_name("barefoo");
|
||||
auto reqMeta = pbReq.mutable_meta();
|
||||
reqMeta->set_rpcname("getHello");
|
||||
pbReq.set_message("Whats your name?");
|
||||
|
||||
std::string rawReq;
|
||||
pbReq.SerializeToString(&rawReq);
|
||||
@@ -41,13 +49,26 @@ int main(int argc, char** argv) {
|
||||
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;
|
||||
|
||||
// Read binary header
|
||||
std::string resRawHeader;
|
||||
const int rhSize = 8;
|
||||
auto rSize = conn.Read(resRawHeader, rhSize);
|
||||
|
||||
RPCHeader resHeader;
|
||||
resHeader.Decode(resRawHeader);
|
||||
|
||||
auto pSize = resHeader.PacketSize();
|
||||
std::string resData;
|
||||
rSize = conn.Read(resData, pSize);
|
||||
|
||||
control::HelloResult pbRes;
|
||||
pbRes.ParseFromString(resData);
|
||||
std::cout << std::format("res message: {}\n", pbRes.message());
|
||||
std::cout << std::format("error: {}\n", pbRes.meta().error());
|
||||
}
|
||||
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
|
||||
|
||||
|
||||
#include <chrono>
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include <cstdarg>
|
||||
|
||||
#include <logger.hpp>
|
||||
|
||||
Logger logger;
|
||||
static std::mutex mtx;
|
||||
|
||||
Logger::Logger(const std::string ilabel) {
|
||||
label = ilabel;
|
||||
}
|
||||
|
||||
Logger::Logger(void) {
|
||||
label = "global";
|
||||
}
|
||||
void Logger::Log(const std::string& message) {
|
||||
auto now = std::chrono::system_clock::now();
|
||||
std::chrono::zoned_time localnow{std::chrono::current_zone(), now};
|
||||
std::string timenow = std::format("{:%Y-%m-%dT%H:%M:%OS%Z}", localnow);
|
||||
std::lock_guard<std::mutex> lock(mtx);
|
||||
std::cout << std::format("{} {} {}\n", timenow, label, message);
|
||||
}
|
||||
|
||||
|
||||
void Logger::Logf(const std::string& format, ...) {
|
||||
auto now = std::chrono::system_clock::now();
|
||||
std::chrono::zoned_time localnow{std::chrono::current_zone(), now};
|
||||
std::string timenow = std::format("{:%Y-%m-%dT%H:%M:%OS%Z}", localnow);
|
||||
std::lock_guard<std::mutex> lock(mtx);
|
||||
std::printf("%s %s ", timenow.c_str(), label.c_str());
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
std::vprintf(format.data(), args);
|
||||
va_end(args);
|
||||
std::printf("\n");
|
||||
}
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <mutex>
|
||||
#include <ctime>
|
||||
|
||||
|
||||
|
||||
class Logger {
|
||||
private:
|
||||
std::string label;
|
||||
public:
|
||||
Logger(std::string ilabel);
|
||||
Logger();
|
||||
void Log(const std::string& message);
|
||||
void Logf(const std::string& format, ...);
|
||||
};
|
||||
|
||||
extern Logger logger;
|
||||
@@ -16,6 +16,8 @@ public:
|
||||
virtual std::expected<int, std::string> Write(std::string payload);
|
||||
virtual std::expected<int, std::string> Read(std::string& buffer, int size);
|
||||
virtual ~NetClient(void);
|
||||
NetClient(const NetClient&) = delete;
|
||||
NetClient& operator=(const NetClient&) = delete;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -21,7 +21,6 @@ public:
|
||||
|
||||
NetHandler(const NetHandler&) = delete;
|
||||
NetHandler& operator=(const NetHandler&) = delete;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+1
-2
@@ -19,8 +19,7 @@ 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.set_message("foobare");
|
||||
helloRes.SerializeToString(&rawResult);
|
||||
res.append(rawResult);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user