diff --git a/CMakeLists.txt b/CMakeLists.txt index 88fe982..4133fdf 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,15 +61,23 @@ add_library(whisper-com STATIC src/WHISPER/Messages/Leave.cpp - + include/WHISPER/Messages/Ping.hpp + src/WHISPER/Messages/Ping.cpp + include/WHISPER/Messages/Pong.hpp + src/WHISPER/Messages/Pong.cpp + include/WHISPER/Messages/stringData.hpp + src/WHISPER/Messages/stringData.cpp include/WHISPER/Messages/Protos/message.pb.cc include/WHISPER/Messages/Protos/join.pb.cc - include/WHISPER/Messages/Protos/leave.pb.cc + include/WHISPER/Messages/Protos/ping.pb.cc + include/WHISPER/Messages/Protos/pong.pb.cc + include/WHISPER/Messages/Protos/stringData.pb.cc + ) @@ -102,18 +110,18 @@ target_include_directories(whisper-com PUBLIC loguru ) - # add_executable(mainRcv + add_executable(mainRcv - # src/mainRecv.cpp + src/mainRecv.cpp - # ) - # target_link_libraries(mainRcv - # loguru - # whisper-com + ) + target_link_libraries(mainRcv + loguru + whisper-com - # ) + ) # # Everything TEST related diff --git a/include/WHISPER/InternalUDPService.hpp b/include/WHISPER/InternalUDPService.hpp index 928134f..d707488 100644 --- a/include/WHISPER/InternalUDPService.hpp +++ b/include/WHISPER/InternalUDPService.hpp @@ -17,9 +17,10 @@ namespace WHISPER { struct localClient{ std::uint32_t port; std::string addr; + std::uint32_t parentid; std::uint32_t id; zmq::socket_t clientSocket; - + std::time_t lastResponse; }; @@ -74,7 +75,7 @@ namespace WHISPER { public: - InternalUDPService(std::uint32_t id, SourceType owndevicetype,std::uint16_t port, std::string destinationAdress, std::string myAdress); + InternalUDPService(std::uint32_t parentid,std::uint32_t id, SourceType owndevicetype,std::uint16_t port, std::string destinationAdress, std::string myAdress); ~InternalUDPService(); diff --git a/include/WHISPER/Messages/Join.hpp b/include/WHISPER/Messages/Join.hpp index 669568d..b244b41 100644 --- a/include/WHISPER/Messages/Join.hpp +++ b/include/WHISPER/Messages/Join.hpp @@ -18,7 +18,7 @@ namespace WHISPER { Join(std::string receivedMessage); - Join(std::uint32_t deviceID, SourceType src,std::uint32_t port, std::string addr); + Join(std::uint32_t parentID,std::uint32_t deviceID, SourceType src,std::uint32_t port, std::string addr); }; } \ No newline at end of file diff --git a/include/WHISPER/Messages/Leave.hpp b/include/WHISPER/Messages/Leave.hpp index ac993f8..330b59c 100644 --- a/include/WHISPER/Messages/Leave.hpp +++ b/include/WHISPER/Messages/Leave.hpp @@ -18,7 +18,7 @@ namespace WHISPER { Leave(std::string receivedMessage); - Leave(std::uint32_t deviceID, SourceType src,std::uint32_t port, std::string addr); + Leave(std::uint32_t parentID,std::uint32_t deviceID, SourceType src,std::uint32_t port, std::string addr); }; } \ No newline at end of file diff --git a/include/WHISPER/Messages/Message.hpp b/include/WHISPER/Messages/Message.hpp index 4edb725..ee6c306 100644 --- a/include/WHISPER/Messages/Message.hpp +++ b/include/WHISPER/Messages/Message.hpp @@ -31,7 +31,9 @@ namespace WHISPER { /// raw track message RAW_TRACK, /// simple data - SIMPLE + SIMPLE, + /// + STRINGDATA }; // enum class EventType @@ -83,7 +85,7 @@ namespace WHISPER { public: Message()=default; - Message(std::int32_t deviceId, MsgTopics topic, MsgType Type,SourceType src); + Message(std::uint32_t parentId,std::uint32_t deviceId, MsgTopics topic, MsgType Type,SourceType src); Message(std::string msg); /** @@ -95,11 +97,13 @@ namespace WHISPER { ///topic of the message for pub sub std::uint32_t topic_; /// WHISPER::MsgType ot the payload - std::int32_t msgType_; + std::uint32_t msgType_; /// WHISPER::SourceType of the sender - std::int32_t sourceType_; + std::uint32_t sourceType_; /// id of the sender - std::int32_t deviceId_; + std::uint32_t deviceId_; + /// parent id of the sender 0 if its the manager + std::uint32_t parentId_; /** * @brief returns the serialized message diff --git a/include/WHISPER/Messages/Ping.hpp b/include/WHISPER/Messages/Ping.hpp new file mode 100644 index 0000000..47bcdfe --- /dev/null +++ b/include/WHISPER/Messages/Ping.hpp @@ -0,0 +1,23 @@ +#pragma once + + +#include +#include +#include +#include + +namespace WHISPER { + + class Ping : public Message + { + private: + messages::ping::Ping pingMessage; + public: + std::uint32_t port_; + + Ping(std::string receivedMessage); + + Ping(std::uint32_t parentID,std::uint32_t deviceID, SourceType src,std::uint32_t port); + + }; +} \ No newline at end of file diff --git a/include/WHISPER/Messages/Pong.hpp b/include/WHISPER/Messages/Pong.hpp new file mode 100644 index 0000000..48ff95c --- /dev/null +++ b/include/WHISPER/Messages/Pong.hpp @@ -0,0 +1,23 @@ +#pragma once + + +#include +#include +#include +#include + +namespace WHISPER { + + class Pong : public Message + { + private: + messages::pong::Pong message_; + public: + std::uint32_t port_; + + Pong(std::string receivedMessage); + + Pong(std::uint32_t parentID,std::uint32_t deviceID, SourceType src,std::uint32_t port); + + }; +} \ No newline at end of file diff --git a/include/WHISPER/Messages/Protos/message.pb.cc b/include/WHISPER/Messages/Protos/message.pb.cc index 164cb71..b8bb02f 100644 --- a/include/WHISPER/Messages/Protos/message.pb.cc +++ b/include/WHISPER/Messages/Protos/message.pb.cc @@ -26,9 +26,10 @@ PROTOBUF_CONSTEXPR Message::Message( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_.payload_)*/{} , /*decltype(_impl_.topic_)*/0u - , /*decltype(_impl_.msgtype_)*/0 - , /*decltype(_impl_.sourcetype_)*/0 - , /*decltype(_impl_.sourceid_)*/0 + , /*decltype(_impl_.msgtype_)*/0u + , /*decltype(_impl_.sourcetype_)*/0u + , /*decltype(_impl_.sourceid_)*/0u + , /*decltype(_impl_.parentid_)*/0u , /*decltype(_impl_._cached_size_)*/{}} {} struct MessageDefaultTypeInternal { PROTOBUF_CONSTEXPR MessageDefaultTypeInternal() @@ -56,6 +57,7 @@ const uint32_t TableStruct_message_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( PROTOBUF_FIELD_OFFSET(::messages::header::Message, _impl_.msgtype_), PROTOBUF_FIELD_OFFSET(::messages::header::Message, _impl_.sourcetype_), PROTOBUF_FIELD_OFFSET(::messages::header::Message, _impl_.sourceid_), + PROTOBUF_FIELD_OFFSET(::messages::header::Message, _impl_.parentid_), PROTOBUF_FIELD_OFFSET(::messages::header::Message, _impl_.payload_), }; static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { @@ -68,17 +70,18 @@ static const ::_pb::Message* const file_default_instances[] = { const char descriptor_table_protodef_message_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = "\n\rmessage.proto\022\017messages.header\032\031google" - "/protobuf/any.proto\"v\n\007Message\022\r\n\005topic\030" - "\001 \001(\r\022\017\n\007msgType\030\002 \001(\005\022\022\n\nsourceType\030\003 \001" - "(\005\022\020\n\010sourceID\030\004 \001(\005\022%\n\007payload\030\005 \003(\0132\024." - "google.protobuf.Anyb\006proto3" + "/protobuf/any.proto\"\210\001\n\007Message\022\r\n\005topic" + "\030\001 \001(\r\022\017\n\007msgType\030\002 \001(\r\022\022\n\nsourceType\030\003 " + "\001(\r\022\020\n\010sourceID\030\004 \001(\r\022\020\n\010parentID\030\005 \001(\r\022" + "%\n\007payload\030\006 \003(\0132\024.google.protobuf.Anyb\006" + "proto3" ; static const ::_pbi::DescriptorTable* const descriptor_table_message_2eproto_deps[1] = { &::descriptor_table_google_2fprotobuf_2fany_2eproto, }; static ::_pbi::once_flag descriptor_table_message_2eproto_once; const ::_pbi::DescriptorTable descriptor_table_message_2eproto = { - false, false, 187, descriptor_table_protodef_message_2eproto, + false, false, 206, descriptor_table_protodef_message_2eproto, "message.proto", &descriptor_table_message_2eproto_once, descriptor_table_message_2eproto_deps, 1, 1, schemas, file_default_instances, TableStruct_message_2eproto::offsets, @@ -118,12 +121,13 @@ Message::Message(const Message& from) , decltype(_impl_.msgtype_){} , decltype(_impl_.sourcetype_){} , decltype(_impl_.sourceid_){} + , decltype(_impl_.parentid_){} , /*decltype(_impl_._cached_size_)*/{}}; _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::memcpy(&_impl_.topic_, &from._impl_.topic_, - static_cast(reinterpret_cast(&_impl_.sourceid_) - - reinterpret_cast(&_impl_.topic_)) + sizeof(_impl_.sourceid_)); + static_cast(reinterpret_cast(&_impl_.parentid_) - + reinterpret_cast(&_impl_.topic_)) + sizeof(_impl_.parentid_)); // @@protoc_insertion_point(copy_constructor:messages.header.Message) } @@ -134,9 +138,10 @@ inline void Message::SharedCtor( new (&_impl_) Impl_{ decltype(_impl_.payload_){arena} , decltype(_impl_.topic_){0u} - , decltype(_impl_.msgtype_){0} - , decltype(_impl_.sourcetype_){0} - , decltype(_impl_.sourceid_){0} + , decltype(_impl_.msgtype_){0u} + , decltype(_impl_.sourcetype_){0u} + , decltype(_impl_.sourceid_){0u} + , decltype(_impl_.parentid_){0u} , /*decltype(_impl_._cached_size_)*/{} }; } @@ -167,8 +172,8 @@ void Message::Clear() { _impl_.payload_.Clear(); ::memset(&_impl_.topic_, 0, static_cast( - reinterpret_cast(&_impl_.sourceid_) - - reinterpret_cast(&_impl_.topic_)) + sizeof(_impl_.sourceid_)); + reinterpret_cast(&_impl_.parentid_) - + reinterpret_cast(&_impl_.topic_)) + sizeof(_impl_.parentid_)); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } @@ -186,7 +191,7 @@ const char* Message::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) } else goto handle_unusual; continue; - // int32 msgType = 2; + // uint32 msgType = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 16)) { _impl_.msgtype_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); @@ -194,7 +199,7 @@ const char* Message::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) } else goto handle_unusual; continue; - // int32 sourceType = 3; + // uint32 sourceType = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 24)) { _impl_.sourcetype_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); @@ -202,7 +207,7 @@ const char* Message::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) } else goto handle_unusual; continue; - // int32 sourceID = 4; + // uint32 sourceID = 4; case 4: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 32)) { _impl_.sourceid_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); @@ -210,16 +215,24 @@ const char* Message::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) } else goto handle_unusual; continue; - // repeated .google.protobuf.Any payload = 5; + // uint32 parentID = 5; case 5: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 40)) { + _impl_.parentid_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // repeated .google.protobuf.Any payload = 6; + case 6: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 50)) { ptr -= 1; do { ptr += 1; ptr = ctx->ParseMessage(_internal_add_payload(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<42>(ptr)); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<50>(ptr)); } else goto handle_unusual; continue; @@ -258,30 +271,36 @@ uint8_t* Message::_InternalSerialize( target = ::_pbi::WireFormatLite::WriteUInt32ToArray(1, this->_internal_topic(), target); } - // int32 msgType = 2; + // uint32 msgType = 2; if (this->_internal_msgtype() != 0) { target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteInt32ToArray(2, this->_internal_msgtype(), target); + target = ::_pbi::WireFormatLite::WriteUInt32ToArray(2, this->_internal_msgtype(), target); } - // int32 sourceType = 3; + // uint32 sourceType = 3; if (this->_internal_sourcetype() != 0) { target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteInt32ToArray(3, this->_internal_sourcetype(), target); + target = ::_pbi::WireFormatLite::WriteUInt32ToArray(3, this->_internal_sourcetype(), target); } - // int32 sourceID = 4; + // uint32 sourceID = 4; if (this->_internal_sourceid() != 0) { target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteInt32ToArray(4, this->_internal_sourceid(), target); + target = ::_pbi::WireFormatLite::WriteUInt32ToArray(4, this->_internal_sourceid(), target); } - // repeated .google.protobuf.Any payload = 5; + // uint32 parentID = 5; + if (this->_internal_parentid() != 0) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt32ToArray(5, this->_internal_parentid(), target); + } + + // repeated .google.protobuf.Any payload = 6; for (unsigned i = 0, n = static_cast(this->_internal_payload_size()); i < n; i++) { const auto& repfield = this->_internal_payload(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(5, repfield, repfield.GetCachedSize(), target, stream); + InternalWriteMessage(6, repfield, repfield.GetCachedSize(), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { @@ -300,7 +319,7 @@ size_t Message::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - // repeated .google.protobuf.Any payload = 5; + // repeated .google.protobuf.Any payload = 6; total_size += 1UL * this->_internal_payload_size(); for (const auto& msg : this->_impl_.payload_) { total_size += @@ -312,19 +331,24 @@ size_t Message::ByteSizeLong() const { total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_topic()); } - // int32 msgType = 2; + // uint32 msgType = 2; if (this->_internal_msgtype() != 0) { - total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_msgtype()); + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_msgtype()); } - // int32 sourceType = 3; + // uint32 sourceType = 3; if (this->_internal_sourcetype() != 0) { - total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_sourcetype()); + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_sourcetype()); } - // int32 sourceID = 4; + // uint32 sourceID = 4; if (this->_internal_sourceid() != 0) { - total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_sourceid()); + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_sourceid()); + } + + // uint32 parentID = 5; + if (this->_internal_parentid() != 0) { + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_parentid()); } return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); @@ -358,6 +382,9 @@ void Message::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOB if (from._internal_sourceid() != 0) { _this->_internal_set_sourceid(from._internal_sourceid()); } + if (from._internal_parentid() != 0) { + _this->_internal_set_parentid(from._internal_parentid()); + } _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } @@ -377,8 +404,8 @@ void Message::InternalSwap(Message* other) { _internal_metadata_.InternalSwap(&other->_internal_metadata_); _impl_.payload_.InternalSwap(&other->_impl_.payload_); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(Message, _impl_.sourceid_) - + sizeof(Message::_impl_.sourceid_) + PROTOBUF_FIELD_OFFSET(Message, _impl_.parentid_) + + sizeof(Message::_impl_.parentid_) - PROTOBUF_FIELD_OFFSET(Message, _impl_.topic_)>( reinterpret_cast(&_impl_.topic_), reinterpret_cast(&other->_impl_.topic_)); diff --git a/include/WHISPER/Messages/Protos/message.pb.h b/include/WHISPER/Messages/Protos/message.pb.h index f3bd045..acffaa8 100644 --- a/include/WHISPER/Messages/Protos/message.pb.h +++ b/include/WHISPER/Messages/Protos/message.pb.h @@ -181,13 +181,14 @@ class Message final : // accessors ------------------------------------------------------- enum : int { - kPayloadFieldNumber = 5, + kPayloadFieldNumber = 6, kTopicFieldNumber = 1, kMsgTypeFieldNumber = 2, kSourceTypeFieldNumber = 3, kSourceIDFieldNumber = 4, + kParentIDFieldNumber = 5, }; - // repeated .google.protobuf.Any payload = 5; + // repeated .google.protobuf.Any payload = 6; int payload_size() const; private: int _internal_payload_size() const; @@ -214,31 +215,40 @@ class Message final : void _internal_set_topic(uint32_t value); public: - // int32 msgType = 2; + // uint32 msgType = 2; void clear_msgtype(); - int32_t msgtype() const; - void set_msgtype(int32_t value); + uint32_t msgtype() const; + void set_msgtype(uint32_t value); private: - int32_t _internal_msgtype() const; - void _internal_set_msgtype(int32_t value); + uint32_t _internal_msgtype() const; + void _internal_set_msgtype(uint32_t value); public: - // int32 sourceType = 3; + // uint32 sourceType = 3; void clear_sourcetype(); - int32_t sourcetype() const; - void set_sourcetype(int32_t value); + uint32_t sourcetype() const; + void set_sourcetype(uint32_t value); private: - int32_t _internal_sourcetype() const; - void _internal_set_sourcetype(int32_t value); + uint32_t _internal_sourcetype() const; + void _internal_set_sourcetype(uint32_t value); public: - // int32 sourceID = 4; + // uint32 sourceID = 4; void clear_sourceid(); - int32_t sourceid() const; - void set_sourceid(int32_t value); + uint32_t sourceid() const; + void set_sourceid(uint32_t value); private: - int32_t _internal_sourceid() const; - void _internal_set_sourceid(int32_t value); + uint32_t _internal_sourceid() const; + void _internal_set_sourceid(uint32_t value); + public: + + // uint32 parentID = 5; + void clear_parentid(); + uint32_t parentid() const; + void set_parentid(uint32_t value); + private: + uint32_t _internal_parentid() const; + void _internal_set_parentid(uint32_t value); public: // @@protoc_insertion_point(class_scope:messages.header.Message) @@ -251,9 +261,10 @@ class Message final : struct Impl_ { ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Any > payload_; uint32_t topic_; - int32_t msgtype_; - int32_t sourcetype_; - int32_t sourceid_; + uint32_t msgtype_; + uint32_t sourcetype_; + uint32_t sourceid_; + uint32_t parentid_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; }; union { Impl_ _impl_; }; @@ -290,67 +301,87 @@ inline void Message::set_topic(uint32_t value) { // @@protoc_insertion_point(field_set:messages.header.Message.topic) } -// int32 msgType = 2; +// uint32 msgType = 2; inline void Message::clear_msgtype() { - _impl_.msgtype_ = 0; + _impl_.msgtype_ = 0u; } -inline int32_t Message::_internal_msgtype() const { +inline uint32_t Message::_internal_msgtype() const { return _impl_.msgtype_; } -inline int32_t Message::msgtype() const { +inline uint32_t Message::msgtype() const { // @@protoc_insertion_point(field_get:messages.header.Message.msgType) return _internal_msgtype(); } -inline void Message::_internal_set_msgtype(int32_t value) { +inline void Message::_internal_set_msgtype(uint32_t value) { _impl_.msgtype_ = value; } -inline void Message::set_msgtype(int32_t value) { +inline void Message::set_msgtype(uint32_t value) { _internal_set_msgtype(value); // @@protoc_insertion_point(field_set:messages.header.Message.msgType) } -// int32 sourceType = 3; +// uint32 sourceType = 3; inline void Message::clear_sourcetype() { - _impl_.sourcetype_ = 0; + _impl_.sourcetype_ = 0u; } -inline int32_t Message::_internal_sourcetype() const { +inline uint32_t Message::_internal_sourcetype() const { return _impl_.sourcetype_; } -inline int32_t Message::sourcetype() const { +inline uint32_t Message::sourcetype() const { // @@protoc_insertion_point(field_get:messages.header.Message.sourceType) return _internal_sourcetype(); } -inline void Message::_internal_set_sourcetype(int32_t value) { +inline void Message::_internal_set_sourcetype(uint32_t value) { _impl_.sourcetype_ = value; } -inline void Message::set_sourcetype(int32_t value) { +inline void Message::set_sourcetype(uint32_t value) { _internal_set_sourcetype(value); // @@protoc_insertion_point(field_set:messages.header.Message.sourceType) } -// int32 sourceID = 4; +// uint32 sourceID = 4; inline void Message::clear_sourceid() { - _impl_.sourceid_ = 0; + _impl_.sourceid_ = 0u; } -inline int32_t Message::_internal_sourceid() const { +inline uint32_t Message::_internal_sourceid() const { return _impl_.sourceid_; } -inline int32_t Message::sourceid() const { +inline uint32_t Message::sourceid() const { // @@protoc_insertion_point(field_get:messages.header.Message.sourceID) return _internal_sourceid(); } -inline void Message::_internal_set_sourceid(int32_t value) { +inline void Message::_internal_set_sourceid(uint32_t value) { _impl_.sourceid_ = value; } -inline void Message::set_sourceid(int32_t value) { +inline void Message::set_sourceid(uint32_t value) { _internal_set_sourceid(value); // @@protoc_insertion_point(field_set:messages.header.Message.sourceID) } -// repeated .google.protobuf.Any payload = 5; +// uint32 parentID = 5; +inline void Message::clear_parentid() { + _impl_.parentid_ = 0u; +} +inline uint32_t Message::_internal_parentid() const { + return _impl_.parentid_; +} +inline uint32_t Message::parentid() const { + // @@protoc_insertion_point(field_get:messages.header.Message.parentID) + return _internal_parentid(); +} +inline void Message::_internal_set_parentid(uint32_t value) { + + _impl_.parentid_ = value; +} +inline void Message::set_parentid(uint32_t value) { + _internal_set_parentid(value); + // @@protoc_insertion_point(field_set:messages.header.Message.parentID) +} + +// repeated .google.protobuf.Any payload = 6; inline int Message::_internal_payload_size() const { return _impl_.payload_.size(); } diff --git a/include/WHISPER/Messages/Protos/message.proto b/include/WHISPER/Messages/Protos/message.proto index 2838dbf..820e29c 100644 --- a/include/WHISPER/Messages/Protos/message.proto +++ b/include/WHISPER/Messages/Protos/message.proto @@ -8,11 +8,12 @@ package messages.header; // [START messages] message Message { uint32 topic = 1; - int32 msgType = 2; - int32 sourceType = 3; - int32 sourceID = 4; + uint32 msgType = 2; + uint32 sourceType = 3; + uint32 sourceID = 4; + uint32 parentID = 5; - repeated google.protobuf.Any payload = 5; + repeated google.protobuf.Any payload = 6; } diff --git a/include/WHISPER/Messages/Protos/ping.pb.cc b/include/WHISPER/Messages/Protos/ping.pb.cc new file mode 100644 index 0000000..0c4f38b --- /dev/null +++ b/include/WHISPER/Messages/Protos/ping.pb.cc @@ -0,0 +1,272 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: ping.proto + +#include "ping.pb.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +// @@protoc_insertion_point(includes) +#include + +PROTOBUF_PRAGMA_INIT_SEG + +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = _pb::internal; + +namespace messages { +namespace ping { +PROTOBUF_CONSTEXPR Ping::Ping( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.port_)*/0u + , /*decltype(_impl_._cached_size_)*/{}} {} +struct PingDefaultTypeInternal { + PROTOBUF_CONSTEXPR PingDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} + ~PingDefaultTypeInternal() {} + union { + Ping _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 PingDefaultTypeInternal _Ping_default_instance_; +} // namespace ping +} // namespace messages +static ::_pb::Metadata file_level_metadata_ping_2eproto[1]; +static constexpr ::_pb::EnumDescriptor const** file_level_enum_descriptors_ping_2eproto = nullptr; +static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_ping_2eproto = nullptr; + +const uint32_t TableStruct_ping_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::messages::ping::Ping, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::messages::ping::Ping, _impl_.port_), +}; +static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, -1, -1, sizeof(::messages::ping::Ping)}, +}; + +static const ::_pb::Message* const file_default_instances[] = { + &::messages::ping::_Ping_default_instance_._instance, +}; + +const char descriptor_table_protodef_ping_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = + "\n\nping.proto\022\rmessages.ping\"\024\n\004Ping\022\014\n\004p" + "ort\030\002 \001(\rb\006proto3" + ; +static ::_pbi::once_flag descriptor_table_ping_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_ping_2eproto = { + false, false, 57, descriptor_table_protodef_ping_2eproto, + "ping.proto", + &descriptor_table_ping_2eproto_once, nullptr, 0, 1, + schemas, file_default_instances, TableStruct_ping_2eproto::offsets, + file_level_metadata_ping_2eproto, file_level_enum_descriptors_ping_2eproto, + file_level_service_descriptors_ping_2eproto, +}; +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_ping_2eproto_getter() { + return &descriptor_table_ping_2eproto; +} + +// Force running AddDescriptors() at dynamic initialization time. +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_ping_2eproto(&descriptor_table_ping_2eproto); +namespace messages { +namespace ping { + +// =================================================================== + +class Ping::_Internal { + public: +}; + +Ping::Ping(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned) + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); + // @@protoc_insertion_point(arena_constructor:messages.ping.Ping) +} +Ping::Ping(const Ping& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + Ping* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.port_){} + , /*decltype(_impl_._cached_size_)*/{}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_impl_.port_ = from._impl_.port_; + // @@protoc_insertion_point(copy_constructor:messages.ping.Ping) +} + +inline void Ping::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.port_){0u} + , /*decltype(_impl_._cached_size_)*/{} + }; +} + +Ping::~Ping() { + // @@protoc_insertion_point(destructor:messages.ping.Ping) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void Ping::SharedDtor() { + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); +} + +void Ping::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void Ping::Clear() { +// @@protoc_insertion_point(message_clear_start:messages.ping.Ping) + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.port_ = 0u; + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* Ping::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // uint32 port = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 16)) { + _impl_.port_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +uint8_t* Ping::_InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:messages.ping.Ping) + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // uint32 port = 2; + if (this->_internal_port() != 0) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt32ToArray(2, this->_internal_port(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:messages.ping.Ping) + return target; +} + +size_t Ping::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:messages.ping.Ping) + size_t total_size = 0; + + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // uint32 port = 2; + if (this->_internal_port() != 0) { + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_port()); + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Ping::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + Ping::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Ping::GetClassData() const { return &_class_data_; } + + +void Ping::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:messages.ping.Ping) + GOOGLE_DCHECK_NE(&from, _this); + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if (from._internal_port() != 0) { + _this->_internal_set_port(from._internal_port()); + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void Ping::CopyFrom(const Ping& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:messages.ping.Ping) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Ping::IsInitialized() const { + return true; +} + +void Ping::InternalSwap(Ping* other) { + using std::swap; + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + swap(_impl_.port_, other->_impl_.port_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata Ping::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_ping_2eproto_getter, &descriptor_table_ping_2eproto_once, + file_level_metadata_ping_2eproto[0]); +} + +// @@protoc_insertion_point(namespace_scope) +} // namespace ping +} // namespace messages +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::messages::ping::Ping* +Arena::CreateMaybeMessage< ::messages::ping::Ping >(Arena* arena) { + return Arena::CreateMessageInternal< ::messages::ping::Ping >(arena); +} +PROTOBUF_NAMESPACE_CLOSE + +// @@protoc_insertion_point(global_scope) +#include diff --git a/include/WHISPER/Messages/Protos/ping.pb.h b/include/WHISPER/Messages/Protos/ping.pb.h new file mode 100644 index 0000000..839c30c --- /dev/null +++ b/include/WHISPER/Messages/Protos/ping.pb.h @@ -0,0 +1,251 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: ping.proto + +#ifndef GOOGLE_PROTOBUF_INCLUDED_ping_2eproto +#define GOOGLE_PROTOBUF_INCLUDED_ping_2eproto + +#include +#include + +#include +#if PROTOBUF_VERSION < 3021000 +#error This file was generated by a newer version of protoc which is +#error incompatible with your Protocol Buffer headers. Please update +#error your headers. +#endif +#if 3021012 < PROTOBUF_MIN_PROTOC_VERSION +#error This file was generated by an older version of protoc which is +#error incompatible with your Protocol Buffer headers. Please +#error regenerate this file with a newer version of protoc. +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include // IWYU pragma: export +#include // IWYU pragma: export +#include +// @@protoc_insertion_point(includes) +#include +#define PROTOBUF_INTERNAL_EXPORT_ping_2eproto +PROTOBUF_NAMESPACE_OPEN +namespace internal { +class AnyMetadata; +} // namespace internal +PROTOBUF_NAMESPACE_CLOSE + +// Internal implementation detail -- do not use these members. +struct TableStruct_ping_2eproto { + static const uint32_t offsets[]; +}; +extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_ping_2eproto; +namespace messages { +namespace ping { +class Ping; +struct PingDefaultTypeInternal; +extern PingDefaultTypeInternal _Ping_default_instance_; +} // namespace ping +} // namespace messages +PROTOBUF_NAMESPACE_OPEN +template<> ::messages::ping::Ping* Arena::CreateMaybeMessage<::messages::ping::Ping>(Arena*); +PROTOBUF_NAMESPACE_CLOSE +namespace messages { +namespace ping { + +// =================================================================== + +class Ping final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:messages.ping.Ping) */ { + public: + inline Ping() : Ping(nullptr) {} + ~Ping() override; + explicit PROTOBUF_CONSTEXPR Ping(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + Ping(const Ping& from); + Ping(Ping&& from) noexcept + : Ping() { + *this = ::std::move(from); + } + + inline Ping& operator=(const Ping& from) { + CopyFrom(from); + return *this; + } + inline Ping& operator=(Ping&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const Ping& default_instance() { + return *internal_default_instance(); + } + static inline const Ping* internal_default_instance() { + return reinterpret_cast( + &_Ping_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(Ping& a, Ping& b) { + a.Swap(&b); + } + inline void Swap(Ping* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Ping* other) { + if (other == this) return; + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + Ping* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const Ping& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const Ping& from) { + Ping::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + uint8_t* _InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(Ping* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "messages.ping.Ping"; + } + protected: + explicit Ping(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned = false); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kPortFieldNumber = 2, + }; + // uint32 port = 2; + void clear_port(); + uint32_t port() const; + void set_port(uint32_t value); + private: + uint32_t _internal_port() const; + void _internal_set_port(uint32_t value); + public: + + // @@protoc_insertion_point(class_scope:messages.ping.Ping) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + uint32_t port_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_ping_2eproto; +}; +// =================================================================== + + +// =================================================================== + +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// Ping + +// uint32 port = 2; +inline void Ping::clear_port() { + _impl_.port_ = 0u; +} +inline uint32_t Ping::_internal_port() const { + return _impl_.port_; +} +inline uint32_t Ping::port() const { + // @@protoc_insertion_point(field_get:messages.ping.Ping.port) + return _internal_port(); +} +inline void Ping::_internal_set_port(uint32_t value) { + + _impl_.port_ = value; +} +inline void Ping::set_port(uint32_t value) { + _internal_set_port(value); + // @@protoc_insertion_point(field_set:messages.ping.Ping.port) +} + +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ + +// @@protoc_insertion_point(namespace_scope) + +} // namespace ping +} // namespace messages + +// @@protoc_insertion_point(global_scope) + +#include +#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_ping_2eproto diff --git a/include/WHISPER/Messages/Protos/ping.proto b/include/WHISPER/Messages/Protos/ping.proto new file mode 100644 index 0000000..2357a2b --- /dev/null +++ b/include/WHISPER/Messages/Protos/ping.proto @@ -0,0 +1,14 @@ + +// [START declaration] +syntax = "proto3"; +package messages.ping; + +// import "google/protobuf/timestamp.proto"; +// [END declaration] + + +// [START messages] +message Ping { + uint32 port = 2; +} + diff --git a/include/WHISPER/Messages/Protos/pong.pb.cc b/include/WHISPER/Messages/Protos/pong.pb.cc new file mode 100644 index 0000000..3186398 --- /dev/null +++ b/include/WHISPER/Messages/Protos/pong.pb.cc @@ -0,0 +1,272 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: pong.proto + +#include "pong.pb.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +// @@protoc_insertion_point(includes) +#include + +PROTOBUF_PRAGMA_INIT_SEG + +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = _pb::internal; + +namespace messages { +namespace pong { +PROTOBUF_CONSTEXPR Pong::Pong( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.port_)*/0u + , /*decltype(_impl_._cached_size_)*/{}} {} +struct PongDefaultTypeInternal { + PROTOBUF_CONSTEXPR PongDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} + ~PongDefaultTypeInternal() {} + union { + Pong _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 PongDefaultTypeInternal _Pong_default_instance_; +} // namespace pong +} // namespace messages +static ::_pb::Metadata file_level_metadata_pong_2eproto[1]; +static constexpr ::_pb::EnumDescriptor const** file_level_enum_descriptors_pong_2eproto = nullptr; +static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_pong_2eproto = nullptr; + +const uint32_t TableStruct_pong_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::messages::pong::Pong, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::messages::pong::Pong, _impl_.port_), +}; +static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, -1, -1, sizeof(::messages::pong::Pong)}, +}; + +static const ::_pb::Message* const file_default_instances[] = { + &::messages::pong::_Pong_default_instance_._instance, +}; + +const char descriptor_table_protodef_pong_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = + "\n\npong.proto\022\rmessages.pong\"\024\n\004Pong\022\014\n\004p" + "ort\030\001 \001(\rb\006proto3" + ; +static ::_pbi::once_flag descriptor_table_pong_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_pong_2eproto = { + false, false, 57, descriptor_table_protodef_pong_2eproto, + "pong.proto", + &descriptor_table_pong_2eproto_once, nullptr, 0, 1, + schemas, file_default_instances, TableStruct_pong_2eproto::offsets, + file_level_metadata_pong_2eproto, file_level_enum_descriptors_pong_2eproto, + file_level_service_descriptors_pong_2eproto, +}; +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_pong_2eproto_getter() { + return &descriptor_table_pong_2eproto; +} + +// Force running AddDescriptors() at dynamic initialization time. +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_pong_2eproto(&descriptor_table_pong_2eproto); +namespace messages { +namespace pong { + +// =================================================================== + +class Pong::_Internal { + public: +}; + +Pong::Pong(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned) + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); + // @@protoc_insertion_point(arena_constructor:messages.pong.Pong) +} +Pong::Pong(const Pong& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + Pong* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.port_){} + , /*decltype(_impl_._cached_size_)*/{}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_impl_.port_ = from._impl_.port_; + // @@protoc_insertion_point(copy_constructor:messages.pong.Pong) +} + +inline void Pong::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.port_){0u} + , /*decltype(_impl_._cached_size_)*/{} + }; +} + +Pong::~Pong() { + // @@protoc_insertion_point(destructor:messages.pong.Pong) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void Pong::SharedDtor() { + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); +} + +void Pong::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void Pong::Clear() { +// @@protoc_insertion_point(message_clear_start:messages.pong.Pong) + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.port_ = 0u; + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* Pong::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // uint32 port = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { + _impl_.port_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +uint8_t* Pong::_InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:messages.pong.Pong) + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // uint32 port = 1; + if (this->_internal_port() != 0) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt32ToArray(1, this->_internal_port(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:messages.pong.Pong) + return target; +} + +size_t Pong::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:messages.pong.Pong) + size_t total_size = 0; + + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // uint32 port = 1; + if (this->_internal_port() != 0) { + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_port()); + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Pong::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + Pong::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Pong::GetClassData() const { return &_class_data_; } + + +void Pong::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:messages.pong.Pong) + GOOGLE_DCHECK_NE(&from, _this); + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if (from._internal_port() != 0) { + _this->_internal_set_port(from._internal_port()); + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void Pong::CopyFrom(const Pong& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:messages.pong.Pong) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Pong::IsInitialized() const { + return true; +} + +void Pong::InternalSwap(Pong* other) { + using std::swap; + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + swap(_impl_.port_, other->_impl_.port_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata Pong::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_pong_2eproto_getter, &descriptor_table_pong_2eproto_once, + file_level_metadata_pong_2eproto[0]); +} + +// @@protoc_insertion_point(namespace_scope) +} // namespace pong +} // namespace messages +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::messages::pong::Pong* +Arena::CreateMaybeMessage< ::messages::pong::Pong >(Arena* arena) { + return Arena::CreateMessageInternal< ::messages::pong::Pong >(arena); +} +PROTOBUF_NAMESPACE_CLOSE + +// @@protoc_insertion_point(global_scope) +#include diff --git a/include/WHISPER/Messages/Protos/pong.pb.h b/include/WHISPER/Messages/Protos/pong.pb.h new file mode 100644 index 0000000..7978ec4 --- /dev/null +++ b/include/WHISPER/Messages/Protos/pong.pb.h @@ -0,0 +1,251 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: pong.proto + +#ifndef GOOGLE_PROTOBUF_INCLUDED_pong_2eproto +#define GOOGLE_PROTOBUF_INCLUDED_pong_2eproto + +#include +#include + +#include +#if PROTOBUF_VERSION < 3021000 +#error This file was generated by a newer version of protoc which is +#error incompatible with your Protocol Buffer headers. Please update +#error your headers. +#endif +#if 3021012 < PROTOBUF_MIN_PROTOC_VERSION +#error This file was generated by an older version of protoc which is +#error incompatible with your Protocol Buffer headers. Please +#error regenerate this file with a newer version of protoc. +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include // IWYU pragma: export +#include // IWYU pragma: export +#include +// @@protoc_insertion_point(includes) +#include +#define PROTOBUF_INTERNAL_EXPORT_pong_2eproto +PROTOBUF_NAMESPACE_OPEN +namespace internal { +class AnyMetadata; +} // namespace internal +PROTOBUF_NAMESPACE_CLOSE + +// Internal implementation detail -- do not use these members. +struct TableStruct_pong_2eproto { + static const uint32_t offsets[]; +}; +extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_pong_2eproto; +namespace messages { +namespace pong { +class Pong; +struct PongDefaultTypeInternal; +extern PongDefaultTypeInternal _Pong_default_instance_; +} // namespace pong +} // namespace messages +PROTOBUF_NAMESPACE_OPEN +template<> ::messages::pong::Pong* Arena::CreateMaybeMessage<::messages::pong::Pong>(Arena*); +PROTOBUF_NAMESPACE_CLOSE +namespace messages { +namespace pong { + +// =================================================================== + +class Pong final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:messages.pong.Pong) */ { + public: + inline Pong() : Pong(nullptr) {} + ~Pong() override; + explicit PROTOBUF_CONSTEXPR Pong(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + Pong(const Pong& from); + Pong(Pong&& from) noexcept + : Pong() { + *this = ::std::move(from); + } + + inline Pong& operator=(const Pong& from) { + CopyFrom(from); + return *this; + } + inline Pong& operator=(Pong&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const Pong& default_instance() { + return *internal_default_instance(); + } + static inline const Pong* internal_default_instance() { + return reinterpret_cast( + &_Pong_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(Pong& a, Pong& b) { + a.Swap(&b); + } + inline void Swap(Pong* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Pong* other) { + if (other == this) return; + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + Pong* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const Pong& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const Pong& from) { + Pong::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + uint8_t* _InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(Pong* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "messages.pong.Pong"; + } + protected: + explicit Pong(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned = false); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kPortFieldNumber = 1, + }; + // uint32 port = 1; + void clear_port(); + uint32_t port() const; + void set_port(uint32_t value); + private: + uint32_t _internal_port() const; + void _internal_set_port(uint32_t value); + public: + + // @@protoc_insertion_point(class_scope:messages.pong.Pong) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + uint32_t port_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_pong_2eproto; +}; +// =================================================================== + + +// =================================================================== + +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// Pong + +// uint32 port = 1; +inline void Pong::clear_port() { + _impl_.port_ = 0u; +} +inline uint32_t Pong::_internal_port() const { + return _impl_.port_; +} +inline uint32_t Pong::port() const { + // @@protoc_insertion_point(field_get:messages.pong.Pong.port) + return _internal_port(); +} +inline void Pong::_internal_set_port(uint32_t value) { + + _impl_.port_ = value; +} +inline void Pong::set_port(uint32_t value) { + _internal_set_port(value); + // @@protoc_insertion_point(field_set:messages.pong.Pong.port) +} + +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ + +// @@protoc_insertion_point(namespace_scope) + +} // namespace pong +} // namespace messages + +// @@protoc_insertion_point(global_scope) + +#include +#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_pong_2eproto diff --git a/include/WHISPER/Messages/Protos/pong.proto b/include/WHISPER/Messages/Protos/pong.proto new file mode 100644 index 0000000..3e467f7 --- /dev/null +++ b/include/WHISPER/Messages/Protos/pong.proto @@ -0,0 +1,14 @@ + +// [START declaration] +syntax = "proto3"; +package messages.pong; + +// import "google/protobuf/timestamp.proto"; +// [END declaration] + + +// [START messages] +message Pong { + uint32 port = 1; +} + diff --git a/include/WHISPER/Messages/Protos/stringData.pb.cc b/include/WHISPER/Messages/Protos/stringData.pb.cc new file mode 100644 index 0000000..ee72686 --- /dev/null +++ b/include/WHISPER/Messages/Protos/stringData.pb.cc @@ -0,0 +1,297 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: stringData.proto + +#include "stringData.pb.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +// @@protoc_insertion_point(includes) +#include + +PROTOBUF_PRAGMA_INIT_SEG + +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = _pb::internal; + +namespace messages { +namespace stringData { +PROTOBUF_CONSTEXPR StringData::StringData( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.data_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_._cached_size_)*/{}} {} +struct StringDataDefaultTypeInternal { + PROTOBUF_CONSTEXPR StringDataDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} + ~StringDataDefaultTypeInternal() {} + union { + StringData _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 StringDataDefaultTypeInternal _StringData_default_instance_; +} // namespace stringData +} // namespace messages +static ::_pb::Metadata file_level_metadata_stringData_2eproto[1]; +static constexpr ::_pb::EnumDescriptor const** file_level_enum_descriptors_stringData_2eproto = nullptr; +static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_stringData_2eproto = nullptr; + +const uint32_t TableStruct_stringData_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::messages::stringData::StringData, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::messages::stringData::StringData, _impl_.data_), +}; +static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, -1, -1, sizeof(::messages::stringData::StringData)}, +}; + +static const ::_pb::Message* const file_default_instances[] = { + &::messages::stringData::_StringData_default_instance_._instance, +}; + +const char descriptor_table_protodef_stringData_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = + "\n\020stringData.proto\022\023messages.stringData\"" + "\032\n\nStringData\022\014\n\004data\030\001 \001(\tb\006proto3" + ; +static ::_pbi::once_flag descriptor_table_stringData_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_stringData_2eproto = { + false, false, 75, descriptor_table_protodef_stringData_2eproto, + "stringData.proto", + &descriptor_table_stringData_2eproto_once, nullptr, 0, 1, + schemas, file_default_instances, TableStruct_stringData_2eproto::offsets, + file_level_metadata_stringData_2eproto, file_level_enum_descriptors_stringData_2eproto, + file_level_service_descriptors_stringData_2eproto, +}; +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_stringData_2eproto_getter() { + return &descriptor_table_stringData_2eproto; +} + +// Force running AddDescriptors() at dynamic initialization time. +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_stringData_2eproto(&descriptor_table_stringData_2eproto); +namespace messages { +namespace stringData { + +// =================================================================== + +class StringData::_Internal { + public: +}; + +StringData::StringData(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned) + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); + // @@protoc_insertion_point(arena_constructor:messages.stringData.StringData) +} +StringData::StringData(const StringData& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + StringData* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.data_){} + , /*decltype(_impl_._cached_size_)*/{}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.data_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.data_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (!from._internal_data().empty()) { + _this->_impl_.data_.Set(from._internal_data(), + _this->GetArenaForAllocation()); + } + // @@protoc_insertion_point(copy_constructor:messages.stringData.StringData) +} + +inline void StringData::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.data_){} + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.data_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.data_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} + +StringData::~StringData() { + // @@protoc_insertion_point(destructor:messages.stringData.StringData) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void StringData::SharedDtor() { + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.data_.Destroy(); +} + +void StringData::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void StringData::Clear() { +// @@protoc_insertion_point(message_clear_start:messages.stringData.StringData) + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.data_.ClearToEmpty(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* StringData::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // string data = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { + auto str = _internal_mutable_data(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "messages.stringData.StringData.data")); + } else + goto handle_unusual; + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +uint8_t* StringData::_InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:messages.stringData.StringData) + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // string data = 1; + if (!this->_internal_data().empty()) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + this->_internal_data().data(), static_cast(this->_internal_data().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "messages.stringData.StringData.data"); + target = stream->WriteStringMaybeAliased( + 1, this->_internal_data(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:messages.stringData.StringData) + return target; +} + +size_t StringData::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:messages.stringData.StringData) + size_t total_size = 0; + + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // string data = 1; + if (!this->_internal_data().empty()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_data()); + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData StringData::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + StringData::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*StringData::GetClassData() const { return &_class_data_; } + + +void StringData::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:messages.stringData.StringData) + GOOGLE_DCHECK_NE(&from, _this); + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if (!from._internal_data().empty()) { + _this->_internal_set_data(from._internal_data()); + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void StringData::CopyFrom(const StringData& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:messages.stringData.StringData) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool StringData::IsInitialized() const { + return true; +} + +void StringData::InternalSwap(StringData* other) { + using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.data_, lhs_arena, + &other->_impl_.data_, rhs_arena + ); +} + +::PROTOBUF_NAMESPACE_ID::Metadata StringData::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_stringData_2eproto_getter, &descriptor_table_stringData_2eproto_once, + file_level_metadata_stringData_2eproto[0]); +} + +// @@protoc_insertion_point(namespace_scope) +} // namespace stringData +} // namespace messages +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::messages::stringData::StringData* +Arena::CreateMaybeMessage< ::messages::stringData::StringData >(Arena* arena) { + return Arena::CreateMessageInternal< ::messages::stringData::StringData >(arena); +} +PROTOBUF_NAMESPACE_CLOSE + +// @@protoc_insertion_point(global_scope) +#include diff --git a/include/WHISPER/Messages/Protos/stringData.pb.h b/include/WHISPER/Messages/Protos/stringData.pb.h new file mode 100644 index 0000000..a1c9b01 --- /dev/null +++ b/include/WHISPER/Messages/Protos/stringData.pb.h @@ -0,0 +1,286 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: stringData.proto + +#ifndef GOOGLE_PROTOBUF_INCLUDED_stringData_2eproto +#define GOOGLE_PROTOBUF_INCLUDED_stringData_2eproto + +#include +#include + +#include +#if PROTOBUF_VERSION < 3021000 +#error This file was generated by a newer version of protoc which is +#error incompatible with your Protocol Buffer headers. Please update +#error your headers. +#endif +#if 3021012 < PROTOBUF_MIN_PROTOC_VERSION +#error This file was generated by an older version of protoc which is +#error incompatible with your Protocol Buffer headers. Please +#error regenerate this file with a newer version of protoc. +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include // IWYU pragma: export +#include // IWYU pragma: export +#include +// @@protoc_insertion_point(includes) +#include +#define PROTOBUF_INTERNAL_EXPORT_stringData_2eproto +PROTOBUF_NAMESPACE_OPEN +namespace internal { +class AnyMetadata; +} // namespace internal +PROTOBUF_NAMESPACE_CLOSE + +// Internal implementation detail -- do not use these members. +struct TableStruct_stringData_2eproto { + static const uint32_t offsets[]; +}; +extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_stringData_2eproto; +namespace messages { +namespace stringData { +class StringData; +struct StringDataDefaultTypeInternal; +extern StringDataDefaultTypeInternal _StringData_default_instance_; +} // namespace stringData +} // namespace messages +PROTOBUF_NAMESPACE_OPEN +template<> ::messages::stringData::StringData* Arena::CreateMaybeMessage<::messages::stringData::StringData>(Arena*); +PROTOBUF_NAMESPACE_CLOSE +namespace messages { +namespace stringData { + +// =================================================================== + +class StringData final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:messages.stringData.StringData) */ { + public: + inline StringData() : StringData(nullptr) {} + ~StringData() override; + explicit PROTOBUF_CONSTEXPR StringData(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + StringData(const StringData& from); + StringData(StringData&& from) noexcept + : StringData() { + *this = ::std::move(from); + } + + inline StringData& operator=(const StringData& from) { + CopyFrom(from); + return *this; + } + inline StringData& operator=(StringData&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const StringData& default_instance() { + return *internal_default_instance(); + } + static inline const StringData* internal_default_instance() { + return reinterpret_cast( + &_StringData_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(StringData& a, StringData& b) { + a.Swap(&b); + } + inline void Swap(StringData* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(StringData* other) { + if (other == this) return; + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + StringData* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const StringData& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const StringData& from) { + StringData::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + uint8_t* _InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(StringData* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "messages.stringData.StringData"; + } + protected: + explicit StringData(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned = false); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kDataFieldNumber = 1, + }; + // string data = 1; + void clear_data(); + const std::string& data() const; + template + void set_data(ArgT0&& arg0, ArgT... args); + std::string* mutable_data(); + PROTOBUF_NODISCARD std::string* release_data(); + void set_allocated_data(std::string* data); + private: + const std::string& _internal_data() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_data(const std::string& value); + std::string* _internal_mutable_data(); + public: + + // @@protoc_insertion_point(class_scope:messages.stringData.StringData) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr data_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_stringData_2eproto; +}; +// =================================================================== + + +// =================================================================== + +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// StringData + +// string data = 1; +inline void StringData::clear_data() { + _impl_.data_.ClearToEmpty(); +} +inline const std::string& StringData::data() const { + // @@protoc_insertion_point(field_get:messages.stringData.StringData.data) + return _internal_data(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void StringData::set_data(ArgT0&& arg0, ArgT... args) { + + _impl_.data_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:messages.stringData.StringData.data) +} +inline std::string* StringData::mutable_data() { + std::string* _s = _internal_mutable_data(); + // @@protoc_insertion_point(field_mutable:messages.stringData.StringData.data) + return _s; +} +inline const std::string& StringData::_internal_data() const { + return _impl_.data_.Get(); +} +inline void StringData::_internal_set_data(const std::string& value) { + + _impl_.data_.Set(value, GetArenaForAllocation()); +} +inline std::string* StringData::_internal_mutable_data() { + + return _impl_.data_.Mutable(GetArenaForAllocation()); +} +inline std::string* StringData::release_data() { + // @@protoc_insertion_point(field_release:messages.stringData.StringData.data) + return _impl_.data_.Release(); +} +inline void StringData::set_allocated_data(std::string* data) { + if (data != nullptr) { + + } else { + + } + _impl_.data_.SetAllocated(data, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.data_.IsDefault()) { + _impl_.data_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:messages.stringData.StringData.data) +} + +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ + +// @@protoc_insertion_point(namespace_scope) + +} // namespace stringData +} // namespace messages + +// @@protoc_insertion_point(global_scope) + +#include +#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_stringData_2eproto diff --git a/include/WHISPER/Messages/Protos/stringData.proto b/include/WHISPER/Messages/Protos/stringData.proto new file mode 100644 index 0000000..5b6f823 --- /dev/null +++ b/include/WHISPER/Messages/Protos/stringData.proto @@ -0,0 +1,14 @@ + +// [START declaration] +syntax = "proto3"; +package messages.stringData; + +// import "google/protobuf/timestamp.proto"; +// [END declaration] + + +// [START messages] +message StringData { + string data = 1; +} + diff --git a/include/WHISPER/Messages/stringData.hpp b/include/WHISPER/Messages/stringData.hpp new file mode 100644 index 0000000..54f59d5 --- /dev/null +++ b/include/WHISPER/Messages/stringData.hpp @@ -0,0 +1,24 @@ + +#pragma once + + +#include +#include +#include +#include + +namespace WHISPER { + + class StringData : public Message + { + private: + messages::stringData::StringData message_; + public: + std::string data_; + + StringData(std::string receivedMessage); + + StringData(std::uint32_t parentID,std::uint32_t deviceID, SourceType src,std::string data); + + }; +} \ No newline at end of file diff --git a/include/WHISPER/whisper.hpp b/include/WHISPER/whisper.hpp index 86279e1..d3adbc5 100644 --- a/include/WHISPER/whisper.hpp +++ b/include/WHISPER/whisper.hpp @@ -37,6 +37,8 @@ namespace WHISPER private: /// device ID std::uint32_t ownID_; + /// device ID + std::uint32_t parentID_; /// device Type SourceType ownDeviceType_; @@ -61,7 +63,7 @@ namespace WHISPER public: - whispercomm(std::uint32_t id, SourceType owndevicetype):ownID_(id),ownDeviceType_(owndevicetype) + whispercomm(std::uint32_t parentid,std::uint32_t id, SourceType owndevicetype):parentID_(parentid),ownID_(id),ownDeviceType_(owndevicetype) {}; void connect(std::shared_ptr> receiver); void publish(std::string msg,std::string topic); @@ -70,6 +72,7 @@ namespace WHISPER void unsubscribe(std::string topic); std::uint32_t getOwnID(); + std::uint32_t getParentID(); SourceType getOwnDeviceType(); protected: diff --git a/src/WHISPER/InternalUDPService.cpp b/src/WHISPER/InternalUDPService.cpp index 96433bc..151391d 100644 --- a/src/WHISPER/InternalUDPService.cpp +++ b/src/WHISPER/InternalUDPService.cpp @@ -4,6 +4,8 @@ #include "WHISPER/Messages/Join.hpp" #include "WHISPER/Messages/Leave.hpp" #include "WHISPER/Messages/Message.hpp" +#include "WHISPER/Messages/Ping.hpp" +#include "WHISPER/Messages/Pong.hpp" #include "WHISPER/whisper.hpp" #include #include @@ -23,8 +25,8 @@ namespace WHISPER { - InternalUDPService::InternalUDPService(std::uint32_t id, SourceType owndevicetype,std::uint16_t port, std::string destinationAdress,std::string myAdress): - whispercomm(id, owndevicetype),port_(port),destinationAdress_(destinationAdress),myAdress_(myAdress) + InternalUDPService::InternalUDPService(std::uint32_t parentid,std::uint32_t id, SourceType owndevicetype,std::uint16_t port, std::string destinationAdress,std::string myAdress): + whispercomm(parentid,id, owndevicetype),port_(port),destinationAdress_(destinationAdress),myAdress_(myAdress) { ctx = zmq::context_t(2); sender = zmq::socket_t(ctx,zmq::socket_type::radio); @@ -76,7 +78,7 @@ namespace WHISPER { LOG_S(INFO)<<"own ID: "<< getOwnID(); - WHISPER::Join join(getOwnID(),getOwnDeviceType(),ownReceivingPort_,myAdress_); + WHISPER::Join join(getParentID(),getOwnID(),getOwnDeviceType(),ownReceivingPort_,myAdress_); this->publish(join.serialize(),WHISPER::MsgTopicsMap[WHISPER::MsgTopics::MANAGEMENT]); @@ -85,7 +87,7 @@ namespace WHISPER { void InternalUDPService::derivedDisconnect() { - WHISPER::Leave Leave(getOwnID(),getOwnDeviceType(),ownReceivingPort_,myAdress_); + WHISPER::Leave Leave(getParentID(),getOwnID(),getOwnDeviceType(),ownReceivingPort_,myAdress_); this->publish(Leave.serialize(),WHISPER::MsgTopicsMap[(WHISPER::MsgTopics)Leave.topic_]); unsubscribe(WHISPER::MsgTopicsMap[WHISPER::MsgTopics::MANAGEMENT]); @@ -168,6 +170,7 @@ namespace WHISPER { auto client = std::make_shared(); client->port = join.port; client->id = join.deviceId_; + client->parentid = join.parentId_; client->addr = "udp://"+join.sourceAddr+":" + std::to_string(join.port); client->clientSocket = zmq::socket_t(ctx,zmq::socket_type::radio); @@ -190,7 +193,7 @@ namespace WHISPER { if (localclients.size() > 0) { for (auto it = localclients.begin(); it != localclients.end();it++) { - if (it->get()->port == Leave.port || it->get()->id == Leave.deviceId_) { + if (it->get()->port == Leave.port || (it->get()->id == Leave.deviceId_ && it->get()->parentid == Leave.deviceId_)) { it->get()->clientSocket.close(); it = localclients.erase(it); LOG_S(INFO)<<"client left"; @@ -204,9 +207,24 @@ namespace WHISPER { }else if(msgType == WHISPER::PING) { + if (receivedMessage.deviceId_ != getOwnID() && receivedMessage.parentId_ != getParentID()) + { + WHISPER::Pong pong(getParentID(),getOwnID(),getOwnDeviceType(),ownReceivingPort_); + this->publish(pong.serialize(),WHISPER::MsgTopicsMap[WHISPER::MsgTopics::MANAGEMENT]); + } }else if(msgType == WHISPER::PONG) { + WHISPER::Pong pong(message); + + if (localclients.size() > 0) { + for (auto it = localclients.begin(); it != localclients.end();it++) + { + if (pong.deviceId_ == it->get()->id && pong.parentId_ == it->get()->parentid) { + it->get()->lastResponse = std::time(nullptr); + } + } + } }else { @@ -232,6 +250,7 @@ namespace WHISPER { } + } diff --git a/src/WHISPER/Messages/Join.cpp b/src/WHISPER/Messages/Join.cpp index 95d21c6..3b0075b 100644 --- a/src/WHISPER/Messages/Join.cpp +++ b/src/WHISPER/Messages/Join.cpp @@ -16,6 +16,7 @@ namespace WHISPER { msgType_ = msg.msgtype(); joinMessage = messages::join::Join(); deviceId_ = msg.sourceid(); + parentId_ = msg.parentid(); if ( msg.payload_size()) { if (msg.payload().begin()->Is()) { @@ -26,7 +27,6 @@ namespace WHISPER { sourceAddr = joinMessage.srcaddress(); - } catch (const std::exception& e) { LOG_S(ERROR)< +#include + + + + +namespace WHISPER { + + Ping::Ping(std::string receivedMessage){ + msg = messages::header::Message(); + try { + msg.ParseFromString(receivedMessage); + topic_ = msg.topic(); + sourceType_ = msg.sourcetype(); + msgType_ = msg.msgtype(); + pingMessage = messages::ping::Ping(); + deviceId_ = msg.sourceid(); + parentId_ = msg.parentid(); + + if ( msg.payload_size()) { + if (msg.payload().begin()->Is()) { + msg.payload().begin()->UnpackTo(&pingMessage); + } + } + port_ = pingMessage.port(); + + + + } catch (const std::exception& e) { + LOG_S(ERROR)<(); + payloadMessage->PackFrom(pingMessage); + addPayLoad(payloadMessage); + + + } + + + + +} \ No newline at end of file diff --git a/src/WHISPER/Messages/Pong.cpp b/src/WHISPER/Messages/Pong.cpp new file mode 100644 index 0000000..f9429d1 --- /dev/null +++ b/src/WHISPER/Messages/Pong.cpp @@ -0,0 +1,56 @@ +#include "WHISPER/Messages/Message.hpp" +#include "WHISPER/Messages/Protos/pong.pb.h" +#include +#include + + + + +namespace WHISPER { + + Pong::Pong(std::string receivedMessage){ + msg = messages::header::Message(); + try { + msg.ParseFromString(receivedMessage); + topic_ = msg.topic(); + sourceType_ = msg.sourcetype(); + msgType_ = msg.msgtype(); + message_ = messages::pong::Pong(); + deviceId_ = msg.sourceid(); + parentId_ = msg.parentid(); + + if ( msg.payload_size()) { + if (msg.payload().begin()->Is()) { + msg.payload().begin()->UnpackTo(&message_); + } + } + port_ = message_.port(); + + + + } catch (const std::exception& e) { + LOG_S(ERROR)<(); + payloadMessage->PackFrom(message_); + addPayLoad(payloadMessage); + + + } + + + + +} \ No newline at end of file diff --git a/src/WHISPER/Messages/stringData.cpp b/src/WHISPER/Messages/stringData.cpp new file mode 100644 index 0000000..a528dc3 --- /dev/null +++ b/src/WHISPER/Messages/stringData.cpp @@ -0,0 +1,54 @@ +#include "WHISPER/Messages/Message.hpp" +#include "WHISPER/Messages/Protos/stringData.pb.h" +#include +#include + + + + +namespace WHISPER { + + StringData::StringData(std::string receivedMessage){ + msg = messages::header::Message(); + try { + msg.ParseFromString(receivedMessage); + topic_ = msg.topic(); + sourceType_ = msg.sourcetype(); + msgType_ = msg.msgtype(); + message_ = messages::stringData::StringData(); + deviceId_ = msg.sourceid(); + parentId_ = msg.parentid(); + + if ( msg.payload_size()) { + if (msg.payload().begin()->Is()) { + msg.payload().begin()->UnpackTo(&message_); + } + } + data_ = message_.data(); + + + + } catch (const std::exception& e) { + LOG_S(ERROR)<(); + payloadMessage->PackFrom(message_); + addPayLoad(payloadMessage); + + + } + + + + +} \ No newline at end of file diff --git a/src/WHISPER/whisper.cpp b/src/WHISPER/whisper.cpp index 8d2b05f..3f2acf6 100644 --- a/src/WHISPER/whisper.cpp +++ b/src/WHISPER/whisper.cpp @@ -23,7 +23,11 @@ namespace WHISPER { return ownID_; } - + + std::uint32_t whispercomm::getParentID() + { + return parentID_; + } void whispercomm::connect(std::shared_ptr> receiver) { diff --git a/src/main.cpp b/src/main.cpp index b52d267..43c0ce3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,6 @@ #include "WHISPER/InternalUDPService.hpp" #include "WHISPER/Messages/Message.hpp" +#include "WHISPER/Messages/stringData.hpp" #include #include @@ -43,14 +44,14 @@ int main() // WHISPER::Join join(1,1,WHISPER::SourceType::SHIP,8000,"192.168.1.178"); auto receiver = std::make_shared>(); - WHISPER::InternalUDPService service(1,WHISPER::SHIP,8000,"192.168.0.255","192.168.1.178"); + WHISPER::InternalUDPService service(0,1,WHISPER::SHIP,8000,"127.0.0.255","127.0.0.1"); service.connect(receiver); service.subscribe(WHISPER::MsgTopicsMap[WHISPER::MsgTopics::DATA]); - service.subscribe(WHISPER::MsgTopicsMap[WHISPER::MsgTopics::TRACK]); + // service.subscribe(WHISPER::MsgTopicsMap[WHISPER::MsgTopics::TRACK]); - - // service.publish(join.serialize(), WHISPER::MsgTopicsMap[WHISPER::MsgTopics::MANAGEMENT]); + WHISPER::StringData data(0,1,WHISPER::SHIP,"hello world"); + service.publish(data.serialize(), WHISPER::MsgTopicsMap[WHISPER::MsgTopics::DATA]); @@ -61,18 +62,12 @@ int main() // service.publish(RawTrack.serialize(),WHISPER::MsgTopicsMap[WHISPER::MsgTopics::TRACK]); - // while (running) { - // // zmq::message_t msg(string.begin(),string.end()); - // // msg.set_group("data"); - // // sock.send(msg,zmq::send_flags::none); + while (running) { + service.publish(data.serialize(), WHISPER::MsgTopicsMap[WHISPER::MsgTopics::DATA]); - // // if (size != receiver->size()) { - // // LOG_S(INFO)<<"received messages " << size; - // // size = receiver->size(); - // // } - // std::this_thread::sleep_for(std::chrono::milliseconds(100)); - // } + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + } service.disconnect(); diff --git a/src/mainRecv.cpp b/src/mainRecv.cpp index 4754ee9..86ecb9f 100644 --- a/src/mainRecv.cpp +++ b/src/mainRecv.cpp @@ -1,4 +1,5 @@ #include "WHISPER/Messages/Message.hpp" +#include "WHISPER/Messages/stringData.hpp" #include "zmq.hpp" #include #include @@ -47,7 +48,7 @@ int main() auto receiver = std::make_shared>(); - WHISPER::InternalUDPService service(2,WHISPER::SHIP,8000,"192.168.0.255","192.168.1.178"); + WHISPER::InternalUDPService service(0,2,WHISPER::SHIP,8000,"127.0.0.255","127.0.0.1"); service.subscribe(WHISPER::MsgTopicsMap[WHISPER::MsgTopics::TRACK]); service.subscribe(WHISPER::MsgTopicsMap[WHISPER::MsgTopics::DATA]); @@ -67,14 +68,15 @@ int main() while (running) { if (msgcount != receiver->size()) { LOG_S(INFO)<<"received messages " << receiver->size(); - - auto received = receiver.get()->get(); - auto topic = received.topic_; - LOG_S(INFO)<<"message type is: "<get(msg); + if (received == true) { + if (msg.msgType_ == WHISPER::MsgType::STRINGDATA) { + WHISPER::StringData data(msg.serialize()); + LOG_S(INFO)<size(); // service.publish(received.serialize(), WHISPER::MsgTopicsMap[(WHISPER::MsgTopics)topic]); diff --git a/tests/test_test.cpp b/tests/test_test.cpp index eea1ba3..bdd515c 100644 --- a/tests/test_test.cpp +++ b/tests/test_test.cpp @@ -34,7 +34,7 @@ SCENARIO("A test scenario","[keywords]") { GIVEN("Preliminaries") { - WHISPER::InternalUDPService service(1,WHISPER::SourceType::SIMCOMTROLER,8000,"127.0.0.255","127.0.0.1"); + WHISPER::InternalUDPService service(0,1,WHISPER::SourceType::SIMCOMTROLER,8000,"127.0.0.255","127.0.0.1"); auto receiver = std::make_shared>(); service.connect(receiver) ; // service.subscribe(WHISPER::MsgTopicsMap[WHISPER::MsgTopics::TRACK]);