From fec59f6c21fee3adb780b1eb075cccc26547bc81 Mon Sep 17 00:00:00 2001 From: hungrymonkey Date: Wed, 25 Oct 2017 05:44:41 -0700 Subject: [PATCH 1/9] inital commit that builds, I have to slowly add functionality --- modules/talkingtree/SCsub | 9 + modules/talkingtree/TalkingTree.pb.cc | 759 +++++++++++++++++++++++++ modules/talkingtree/TalkingTree.pb.h | 422 ++++++++++++++ modules/talkingtree/TalkingTree.proto | 15 + modules/talkingtree/register_types.cpp | 3 +- modules/talkingtree/talking_tree.cpp | 10 + modules/talkingtree/talking_tree.h | 20 + 7 files changed, 1237 insertions(+), 1 deletion(-) create mode 100644 modules/talkingtree/TalkingTree.pb.cc create mode 100644 modules/talkingtree/TalkingTree.pb.h create mode 100644 modules/talkingtree/talking_tree.cpp create mode 100644 modules/talkingtree/talking_tree.h diff --git a/modules/talkingtree/SCsub b/modules/talkingtree/SCsub index ddc9ad7ee77e..08e3d65fcd40 100644 --- a/modules/talkingtree/SCsub +++ b/modules/talkingtree/SCsub @@ -2,5 +2,14 @@ Import('env') env_talkingtree = env.Clone() + +talkingtree_dir = '#modules/talkingtree/' +protobuf_proto = 'TalkingTree.proto' + + +protobuf_target = env_talkingtree.Command( 'TalkingTree.pb.cc', \ + protobuf_proto, \ + "protoc --proto_path=. --cpp_out=. $SOURCE") +Depends( env.modules_sources, protobuf_target) env_talkingtree.add_source_files(env.modules_sources,"*.cpp") env_talkingtree.Append(CXXFLAGS=['-O2', '-std=c++11']) diff --git a/modules/talkingtree/TalkingTree.pb.cc b/modules/talkingtree/TalkingTree.pb.cc new file mode 100644 index 000000000000..594e06737473 --- /dev/null +++ b/modules/talkingtree/TalkingTree.pb.cc @@ -0,0 +1,759 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: modules/talkingtree/TalkingTree.proto + +#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION +#include "modules/talkingtree/TalkingTree.pb.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +// @@protoc_insertion_point(includes) + +namespace TalkingTreeProto { +class TextMessageDefaultTypeInternal { +public: + ::google::protobuf::internal::ExplicitlyConstructed + _instance; +} _TextMessage_default_instance_; + +namespace protobuf_modules_2ftalkingtree_2fTalkingTree_2eproto { + + +namespace { + +::google::protobuf::Metadata file_level_metadata[1]; + +} // namespace + +PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTableField + const TableStruct::entries[] GOOGLE_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { + {0, 0, 0, ::google::protobuf::internal::kInvalidMask, 0, 0}, +}; + +PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::AuxillaryParseTableField + const TableStruct::aux[] GOOGLE_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { + ::google::protobuf::internal::AuxillaryParseTableField(), +}; +PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTable const + TableStruct::schema[] GOOGLE_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { + { NULL, NULL, 0, -1, -1, -1, -1, NULL, false }, +}; + +const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TextMessage, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TextMessage, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TextMessage, actor_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TextMessage, session_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TextMessage, channel_id_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TextMessage, tree_id_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TextMessage, message_), + 1, + ~0u, + ~0u, + ~0u, + 0, +}; +static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { + { 0, 10, sizeof(TextMessage)}, +}; + +static ::google::protobuf::Message const * const file_default_instances[] = { + reinterpret_cast(&_TextMessage_default_instance_), +}; + +namespace { + +void protobuf_AssignDescriptors() { + AddDescriptors(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "modules/talkingtree/TalkingTree.proto", schemas, file_default_instances, TableStruct::offsets, factory, + file_level_metadata, NULL, NULL); +} + +void protobuf_AssignDescriptorsOnce() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); +} + +void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; +void protobuf_RegisterTypes(const ::std::string&) { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1); +} + +} // namespace +void TableStruct::InitDefaultsImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + ::google::protobuf::internal::InitProtobufDefaults(); + _TextMessage_default_instance_._instance.DefaultConstruct(); + ::google::protobuf::internal::OnShutdownDestroyMessage( + &_TextMessage_default_instance_);} + +void InitDefaults() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); +} +namespace { +void AddDescriptorsImpl() { + InitDefaults(); + static const char descriptor[] GOOGLE_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { + "\n%modules/talkingtree/TalkingTree.proto\022" + "\020TalkingTreeProto\"c\n\013TextMessage\022\r\n\005acto" + "r\030\001 \001(\r\022\017\n\007session\030\002 \003(\r\022\022\n\nchannel_id\030\003" + " \003(\r\022\017\n\007tree_id\030\004 \003(\r\022\017\n\007message\030\005 \002(\tB\002" + "H\001" + }; + ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( + descriptor, 162); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( + "modules/talkingtree/TalkingTree.proto", &protobuf_RegisterTypes); +} +} // anonymous namespace + +void AddDescriptors() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); +} +// Force AddDescriptors() to be called at dynamic initialization time. +struct StaticDescriptorInitializer { + StaticDescriptorInitializer() { + AddDescriptors(); + } +} static_descriptor_initializer; + +} // namespace protobuf_modules_2ftalkingtree_2fTalkingTree_2eproto + + +// =================================================================== + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const int TextMessage::kActorFieldNumber; +const int TextMessage::kSessionFieldNumber; +const int TextMessage::kChannelIdFieldNumber; +const int TextMessage::kTreeIdFieldNumber; +const int TextMessage::kMessageFieldNumber; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 + +TextMessage::TextMessage() + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_modules_2ftalkingtree_2fTalkingTree_2eproto::InitDefaults(); + } + SharedCtor(); + // @@protoc_insertion_point(constructor:TalkingTreeProto.TextMessage) +} +TextMessage::TextMessage(const TextMessage& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + session_(from.session_), + channel_id_(from.channel_id_), + tree_id_(from.tree_id_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + message_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_message()) { + message_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.message_); + } + actor_ = from.actor_; + // @@protoc_insertion_point(copy_constructor:TalkingTreeProto.TextMessage) +} + +void TextMessage::SharedCtor() { + _cached_size_ = 0; + message_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + actor_ = 0u; +} + +TextMessage::~TextMessage() { + // @@protoc_insertion_point(destructor:TalkingTreeProto.TextMessage) + SharedDtor(); +} + +void TextMessage::SharedDtor() { + message_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + +void TextMessage::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* TextMessage::descriptor() { + protobuf_modules_2ftalkingtree_2fTalkingTree_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_modules_2ftalkingtree_2fTalkingTree_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; +} + +const TextMessage& TextMessage::default_instance() { + protobuf_modules_2ftalkingtree_2fTalkingTree_2eproto::InitDefaults(); + return *internal_default_instance(); +} + +TextMessage* TextMessage::New(::google::protobuf::Arena* arena) const { + TextMessage* n = new TextMessage; + if (arena != NULL) { + arena->Own(n); + } + return n; +} + +void TextMessage::Clear() { +// @@protoc_insertion_point(message_clear_start:TalkingTreeProto.TextMessage) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + session_.Clear(); + channel_id_.Clear(); + tree_id_.Clear(); + if (has_message()) { + GOOGLE_DCHECK(!message_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*message_.UnsafeRawStringPointer())->clear(); + } + actor_ = 0u; + _has_bits_.Clear(); + _internal_metadata_.Clear(); +} + +bool TextMessage::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure + ::google::protobuf::uint32 tag; + // @@protoc_insertion_point(parse_start:TalkingTreeProto.TextMessage) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); + tag = p.first; + if (!p.second) goto handle_unusual; + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // optional uint32 actor = 1; + case 1: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) { + set_has_actor(); + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( + input, &actor_))); + } else { + goto handle_unusual; + } + break; + } + + // repeated uint32 session = 2; + case 2: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) { + DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< + ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( + 1, 16u, input, this->mutable_session()))); + } else if ( + static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) { + DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< + ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( + input, this->mutable_session()))); + } else { + goto handle_unusual; + } + break; + } + + // repeated uint32 channel_id = 3; + case 3: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(24u /* 24 & 0xFF */)) { + DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< + ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( + 1, 24u, input, this->mutable_channel_id()))); + } else if ( + static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) { + DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< + ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( + input, this->mutable_channel_id()))); + } else { + goto handle_unusual; + } + break; + } + + // repeated uint32 tree_id = 4; + case 4: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(32u /* 32 & 0xFF */)) { + DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< + ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( + 1, 32u, input, this->mutable_tree_id()))); + } else if ( + static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(34u /* 34 & 0xFF */)) { + DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< + ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( + input, this->mutable_tree_id()))); + } else { + goto handle_unusual; + } + break; + } + + // required string message = 5; + case 5: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(42u /* 42 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_message())); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->message().data(), static_cast(this->message().length()), + ::google::protobuf::internal::WireFormat::PARSE, + "TalkingTreeProto.TextMessage.message"); + } else { + goto handle_unusual; + } + break; + } + + default: { + handle_unusual: + if (tag == 0) { + goto success; + } + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, _internal_metadata_.mutable_unknown_fields())); + break; + } + } + } +success: + // @@protoc_insertion_point(parse_success:TalkingTreeProto.TextMessage) + return true; +failure: + // @@protoc_insertion_point(parse_failure:TalkingTreeProto.TextMessage) + return false; +#undef DO_ +} + +void TextMessage::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:TalkingTreeProto.TextMessage) + ::google::protobuf::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // optional uint32 actor = 1; + if (cached_has_bits & 0x00000002u) { + ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->actor(), output); + } + + // repeated uint32 session = 2; + for (int i = 0, n = this->session_size(); i < n; i++) { + ::google::protobuf::internal::WireFormatLite::WriteUInt32( + 2, this->session(i), output); + } + + // repeated uint32 channel_id = 3; + for (int i = 0, n = this->channel_id_size(); i < n; i++) { + ::google::protobuf::internal::WireFormatLite::WriteUInt32( + 3, this->channel_id(i), output); + } + + // repeated uint32 tree_id = 4; + for (int i = 0, n = this->tree_id_size(); i < n; i++) { + ::google::protobuf::internal::WireFormatLite::WriteUInt32( + 4, this->tree_id(i), output); + } + + // required string message = 5; + if (cached_has_bits & 0x00000001u) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->message().data(), static_cast(this->message().length()), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "TalkingTreeProto.TextMessage.message"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( + 5, this->message(), output); + } + + if (_internal_metadata_.have_unknown_fields()) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + _internal_metadata_.unknown_fields(), output); + } + // @@protoc_insertion_point(serialize_end:TalkingTreeProto.TextMessage) +} + +::google::protobuf::uint8* TextMessage::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:TalkingTreeProto.TextMessage) + ::google::protobuf::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // optional uint32 actor = 1; + if (cached_has_bits & 0x00000002u) { + target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->actor(), target); + } + + // repeated uint32 session = 2; + target = ::google::protobuf::internal::WireFormatLite:: + WriteUInt32ToArray(2, this->session_, target); + + // repeated uint32 channel_id = 3; + target = ::google::protobuf::internal::WireFormatLite:: + WriteUInt32ToArray(3, this->channel_id_, target); + + // repeated uint32 tree_id = 4; + target = ::google::protobuf::internal::WireFormatLite:: + WriteUInt32ToArray(4, this->tree_id_, target); + + // required string message = 5; + if (cached_has_bits & 0x00000001u) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->message().data(), static_cast(this->message().length()), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "TalkingTreeProto.TextMessage.message"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 5, this->message(), target); + } + + if (_internal_metadata_.have_unknown_fields()) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields(), target); + } + // @@protoc_insertion_point(serialize_to_array_end:TalkingTreeProto.TextMessage) + return target; +} + +size_t TextMessage::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:TalkingTreeProto.TextMessage) + size_t total_size = 0; + + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + _internal_metadata_.unknown_fields()); + } + // required string message = 5; + if (has_message()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->message()); + } + // repeated uint32 session = 2; + { + size_t data_size = ::google::protobuf::internal::WireFormatLite:: + UInt32Size(this->session_); + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->session_size()); + total_size += data_size; + } + + // repeated uint32 channel_id = 3; + { + size_t data_size = ::google::protobuf::internal::WireFormatLite:: + UInt32Size(this->channel_id_); + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->channel_id_size()); + total_size += data_size; + } + + // repeated uint32 tree_id = 4; + { + size_t data_size = ::google::protobuf::internal::WireFormatLite:: + UInt32Size(this->tree_id_); + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->tree_id_size()); + total_size += data_size; + } + + // optional uint32 actor = 1; + if (has_actor()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->actor()); + } + + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = cached_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void TextMessage::MergeFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:TalkingTreeProto.TextMessage) + GOOGLE_DCHECK_NE(&from, this); + const TextMessage* source = + ::google::protobuf::internal::DynamicCastToGenerated( + &from); + if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:TalkingTreeProto.TextMessage) + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:TalkingTreeProto.TextMessage) + MergeFrom(*source); + } +} + +void TextMessage::MergeFrom(const TextMessage& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:TalkingTreeProto.TextMessage) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + ::google::protobuf::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + session_.MergeFrom(from.session_); + channel_id_.MergeFrom(from.channel_id_); + tree_id_.MergeFrom(from.tree_id_); + cached_has_bits = from._has_bits_[0]; + if (cached_has_bits & 3u) { + if (cached_has_bits & 0x00000001u) { + set_has_message(); + message_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.message_); + } + if (cached_has_bits & 0x00000002u) { + actor_ = from.actor_; + } + _has_bits_[0] |= cached_has_bits; + } +} + +void TextMessage::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:TalkingTreeProto.TextMessage) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void TextMessage::CopyFrom(const TextMessage& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:TalkingTreeProto.TextMessage) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool TextMessage::IsInitialized() const { + if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false; + return true; +} + +void TextMessage::Swap(TextMessage* other) { + if (other == this) return; + InternalSwap(other); +} +void TextMessage::InternalSwap(TextMessage* other) { + using std::swap; + session_.InternalSwap(&other->session_); + channel_id_.InternalSwap(&other->channel_id_); + tree_id_.InternalSwap(&other->tree_id_); + message_.Swap(&other->message_); + swap(actor_, other->actor_); + swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + swap(_cached_size_, other->_cached_size_); +} + +::google::protobuf::Metadata TextMessage::GetMetadata() const { + protobuf_modules_2ftalkingtree_2fTalkingTree_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_modules_2ftalkingtree_2fTalkingTree_2eproto::file_level_metadata[kIndexInFileMessages]; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// TextMessage + +// optional uint32 actor = 1; +bool TextMessage::has_actor() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void TextMessage::set_has_actor() { + _has_bits_[0] |= 0x00000002u; +} +void TextMessage::clear_has_actor() { + _has_bits_[0] &= ~0x00000002u; +} +void TextMessage::clear_actor() { + actor_ = 0u; + clear_has_actor(); +} +::google::protobuf::uint32 TextMessage::actor() const { + // @@protoc_insertion_point(field_get:TalkingTreeProto.TextMessage.actor) + return actor_; +} +void TextMessage::set_actor(::google::protobuf::uint32 value) { + set_has_actor(); + actor_ = value; + // @@protoc_insertion_point(field_set:TalkingTreeProto.TextMessage.actor) +} + +// repeated uint32 session = 2; +int TextMessage::session_size() const { + return session_.size(); +} +void TextMessage::clear_session() { + session_.Clear(); +} +::google::protobuf::uint32 TextMessage::session(int index) const { + // @@protoc_insertion_point(field_get:TalkingTreeProto.TextMessage.session) + return session_.Get(index); +} +void TextMessage::set_session(int index, ::google::protobuf::uint32 value) { + session_.Set(index, value); + // @@protoc_insertion_point(field_set:TalkingTreeProto.TextMessage.session) +} +void TextMessage::add_session(::google::protobuf::uint32 value) { + session_.Add(value); + // @@protoc_insertion_point(field_add:TalkingTreeProto.TextMessage.session) +} +const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& +TextMessage::session() const { + // @@protoc_insertion_point(field_list:TalkingTreeProto.TextMessage.session) + return session_; +} +::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* +TextMessage::mutable_session() { + // @@protoc_insertion_point(field_mutable_list:TalkingTreeProto.TextMessage.session) + return &session_; +} + +// repeated uint32 channel_id = 3; +int TextMessage::channel_id_size() const { + return channel_id_.size(); +} +void TextMessage::clear_channel_id() { + channel_id_.Clear(); +} +::google::protobuf::uint32 TextMessage::channel_id(int index) const { + // @@protoc_insertion_point(field_get:TalkingTreeProto.TextMessage.channel_id) + return channel_id_.Get(index); +} +void TextMessage::set_channel_id(int index, ::google::protobuf::uint32 value) { + channel_id_.Set(index, value); + // @@protoc_insertion_point(field_set:TalkingTreeProto.TextMessage.channel_id) +} +void TextMessage::add_channel_id(::google::protobuf::uint32 value) { + channel_id_.Add(value); + // @@protoc_insertion_point(field_add:TalkingTreeProto.TextMessage.channel_id) +} +const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& +TextMessage::channel_id() const { + // @@protoc_insertion_point(field_list:TalkingTreeProto.TextMessage.channel_id) + return channel_id_; +} +::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* +TextMessage::mutable_channel_id() { + // @@protoc_insertion_point(field_mutable_list:TalkingTreeProto.TextMessage.channel_id) + return &channel_id_; +} + +// repeated uint32 tree_id = 4; +int TextMessage::tree_id_size() const { + return tree_id_.size(); +} +void TextMessage::clear_tree_id() { + tree_id_.Clear(); +} +::google::protobuf::uint32 TextMessage::tree_id(int index) const { + // @@protoc_insertion_point(field_get:TalkingTreeProto.TextMessage.tree_id) + return tree_id_.Get(index); +} +void TextMessage::set_tree_id(int index, ::google::protobuf::uint32 value) { + tree_id_.Set(index, value); + // @@protoc_insertion_point(field_set:TalkingTreeProto.TextMessage.tree_id) +} +void TextMessage::add_tree_id(::google::protobuf::uint32 value) { + tree_id_.Add(value); + // @@protoc_insertion_point(field_add:TalkingTreeProto.TextMessage.tree_id) +} +const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& +TextMessage::tree_id() const { + // @@protoc_insertion_point(field_list:TalkingTreeProto.TextMessage.tree_id) + return tree_id_; +} +::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* +TextMessage::mutable_tree_id() { + // @@protoc_insertion_point(field_mutable_list:TalkingTreeProto.TextMessage.tree_id) + return &tree_id_; +} + +// required string message = 5; +bool TextMessage::has_message() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void TextMessage::set_has_message() { + _has_bits_[0] |= 0x00000001u; +} +void TextMessage::clear_has_message() { + _has_bits_[0] &= ~0x00000001u; +} +void TextMessage::clear_message() { + message_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_message(); +} +const ::std::string& TextMessage::message() const { + // @@protoc_insertion_point(field_get:TalkingTreeProto.TextMessage.message) + return message_.GetNoArena(); +} +void TextMessage::set_message(const ::std::string& value) { + set_has_message(); + message_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:TalkingTreeProto.TextMessage.message) +} +#if LANG_CXX11 +void TextMessage::set_message(::std::string&& value) { + set_has_message(); + message_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:TalkingTreeProto.TextMessage.message) +} +#endif +void TextMessage::set_message(const char* value) { + GOOGLE_DCHECK(value != NULL); + set_has_message(); + message_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:TalkingTreeProto.TextMessage.message) +} +void TextMessage::set_message(const char* value, size_t size) { + set_has_message(); + message_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:TalkingTreeProto.TextMessage.message) +} +::std::string* TextMessage::mutable_message() { + set_has_message(); + // @@protoc_insertion_point(field_mutable:TalkingTreeProto.TextMessage.message) + return message_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* TextMessage::release_message() { + // @@protoc_insertion_point(field_release:TalkingTreeProto.TextMessage.message) + clear_has_message(); + return message_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void TextMessage::set_allocated_message(::std::string* message) { + if (message != NULL) { + set_has_message(); + } else { + clear_has_message(); + } + message_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), message); + // @@protoc_insertion_point(field_set_allocated:TalkingTreeProto.TextMessage.message) +} + +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS + +// @@protoc_insertion_point(namespace_scope) + +} // namespace TalkingTreeProto + +// @@protoc_insertion_point(global_scope) diff --git a/modules/talkingtree/TalkingTree.pb.h b/modules/talkingtree/TalkingTree.pb.h new file mode 100644 index 000000000000..6c13ac59376b --- /dev/null +++ b/modules/talkingtree/TalkingTree.pb.h @@ -0,0 +1,422 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: modules/talkingtree/TalkingTree.proto + +#ifndef PROTOBUF_modules_2ftalkingtree_2fTalkingTree_2eproto__INCLUDED +#define PROTOBUF_modules_2ftalkingtree_2fTalkingTree_2eproto__INCLUDED + +#include + +#include + +#if GOOGLE_PROTOBUF_VERSION < 3004000 +#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 3004000 < GOOGLE_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 // IWYU pragma: export +#include // IWYU pragma: export +#include +// @@protoc_insertion_point(includes) +namespace TalkingTreeProto { +class TextMessage; +class TextMessageDefaultTypeInternal; +extern TextMessageDefaultTypeInternal _TextMessage_default_instance_; +} // namespace TalkingTreeProto + +namespace TalkingTreeProto { + +namespace protobuf_modules_2ftalkingtree_2fTalkingTree_2eproto { +// Internal implementation detail -- do not call these. +struct TableStruct { + static const ::google::protobuf::internal::ParseTableField entries[]; + static const ::google::protobuf::internal::AuxillaryParseTableField aux[]; + static const ::google::protobuf::internal::ParseTable schema[]; + static const ::google::protobuf::uint32 offsets[]; + static const ::google::protobuf::internal::FieldMetadata field_metadata[]; + static const ::google::protobuf::internal::SerializationTable serialization_table[]; + static void InitDefaultsImpl(); +}; +void AddDescriptors(); +void InitDefaults(); +} // namespace protobuf_modules_2ftalkingtree_2fTalkingTree_2eproto + +// =================================================================== + +class TextMessage : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:TalkingTreeProto.TextMessage) */ { + public: + TextMessage(); + virtual ~TextMessage(); + + TextMessage(const TextMessage& from); + + inline TextMessage& operator=(const TextMessage& from) { + CopyFrom(from); + return *this; + } + #if LANG_CXX11 + TextMessage(TextMessage&& from) noexcept + : TextMessage() { + *this = ::std::move(from); + } + + inline TextMessage& operator=(TextMessage&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields(); + } + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const TextMessage& default_instance(); + + static inline const TextMessage* internal_default_instance() { + return reinterpret_cast( + &_TextMessage_default_instance_); + } + static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = + 0; + + void Swap(TextMessage* other); + friend void swap(TextMessage& a, TextMessage& b) { + a.Swap(&b); + } + + // implements Message ---------------------------------------------- + + inline TextMessage* New() const PROTOBUF_FINAL { return New(NULL); } + + TextMessage* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void CopyFrom(const TextMessage& from); + void MergeFrom(const TextMessage& from); + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; + + size_t ByteSizeLong() const PROTOBUF_FINAL; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const PROTOBUF_FINAL; + void InternalSwap(TextMessage* other); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return NULL; + } + inline void* MaybeArenaPtr() const { + return NULL; + } + public: + + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // repeated uint32 session = 2; + int session_size() const; + void clear_session(); + static const int kSessionFieldNumber = 2; + ::google::protobuf::uint32 session(int index) const; + void set_session(int index, ::google::protobuf::uint32 value); + void add_session(::google::protobuf::uint32 value); + const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& + session() const; + ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* + mutable_session(); + + // repeated uint32 channel_id = 3; + int channel_id_size() const; + void clear_channel_id(); + static const int kChannelIdFieldNumber = 3; + ::google::protobuf::uint32 channel_id(int index) const; + void set_channel_id(int index, ::google::protobuf::uint32 value); + void add_channel_id(::google::protobuf::uint32 value); + const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& + channel_id() const; + ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* + mutable_channel_id(); + + // repeated uint32 tree_id = 4; + int tree_id_size() const; + void clear_tree_id(); + static const int kTreeIdFieldNumber = 4; + ::google::protobuf::uint32 tree_id(int index) const; + void set_tree_id(int index, ::google::protobuf::uint32 value); + void add_tree_id(::google::protobuf::uint32 value); + const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& + tree_id() const; + ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* + mutable_tree_id(); + + // required string message = 5; + bool has_message() const; + void clear_message(); + static const int kMessageFieldNumber = 5; + const ::std::string& message() const; + void set_message(const ::std::string& value); + #if LANG_CXX11 + void set_message(::std::string&& value); + #endif + void set_message(const char* value); + void set_message(const char* value, size_t size); + ::std::string* mutable_message(); + ::std::string* release_message(); + void set_allocated_message(::std::string* message); + + // optional uint32 actor = 1; + bool has_actor() const; + void clear_actor(); + static const int kActorFieldNumber = 1; + ::google::protobuf::uint32 actor() const; + void set_actor(::google::protobuf::uint32 value); + + // @@protoc_insertion_point(class_scope:TalkingTreeProto.TextMessage) + private: + void set_has_actor(); + void clear_has_actor(); + void set_has_message(); + void clear_has_message(); + + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; + ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > session_; + ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > channel_id_; + ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > tree_id_; + ::google::protobuf::internal::ArenaStringPtr message_; + ::google::protobuf::uint32 actor_; + friend struct protobuf_modules_2ftalkingtree_2fTalkingTree_2eproto::TableStruct; +}; +// =================================================================== + + +// =================================================================== + +#if !PROTOBUF_INLINE_NOT_IN_HEADERS +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// TextMessage + +// optional uint32 actor = 1; +inline bool TextMessage::has_actor() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +inline void TextMessage::set_has_actor() { + _has_bits_[0] |= 0x00000002u; +} +inline void TextMessage::clear_has_actor() { + _has_bits_[0] &= ~0x00000002u; +} +inline void TextMessage::clear_actor() { + actor_ = 0u; + clear_has_actor(); +} +inline ::google::protobuf::uint32 TextMessage::actor() const { + // @@protoc_insertion_point(field_get:TalkingTreeProto.TextMessage.actor) + return actor_; +} +inline void TextMessage::set_actor(::google::protobuf::uint32 value) { + set_has_actor(); + actor_ = value; + // @@protoc_insertion_point(field_set:TalkingTreeProto.TextMessage.actor) +} + +// repeated uint32 session = 2; +inline int TextMessage::session_size() const { + return session_.size(); +} +inline void TextMessage::clear_session() { + session_.Clear(); +} +inline ::google::protobuf::uint32 TextMessage::session(int index) const { + // @@protoc_insertion_point(field_get:TalkingTreeProto.TextMessage.session) + return session_.Get(index); +} +inline void TextMessage::set_session(int index, ::google::protobuf::uint32 value) { + session_.Set(index, value); + // @@protoc_insertion_point(field_set:TalkingTreeProto.TextMessage.session) +} +inline void TextMessage::add_session(::google::protobuf::uint32 value) { + session_.Add(value); + // @@protoc_insertion_point(field_add:TalkingTreeProto.TextMessage.session) +} +inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& +TextMessage::session() const { + // @@protoc_insertion_point(field_list:TalkingTreeProto.TextMessage.session) + return session_; +} +inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* +TextMessage::mutable_session() { + // @@protoc_insertion_point(field_mutable_list:TalkingTreeProto.TextMessage.session) + return &session_; +} + +// repeated uint32 channel_id = 3; +inline int TextMessage::channel_id_size() const { + return channel_id_.size(); +} +inline void TextMessage::clear_channel_id() { + channel_id_.Clear(); +} +inline ::google::protobuf::uint32 TextMessage::channel_id(int index) const { + // @@protoc_insertion_point(field_get:TalkingTreeProto.TextMessage.channel_id) + return channel_id_.Get(index); +} +inline void TextMessage::set_channel_id(int index, ::google::protobuf::uint32 value) { + channel_id_.Set(index, value); + // @@protoc_insertion_point(field_set:TalkingTreeProto.TextMessage.channel_id) +} +inline void TextMessage::add_channel_id(::google::protobuf::uint32 value) { + channel_id_.Add(value); + // @@protoc_insertion_point(field_add:TalkingTreeProto.TextMessage.channel_id) +} +inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& +TextMessage::channel_id() const { + // @@protoc_insertion_point(field_list:TalkingTreeProto.TextMessage.channel_id) + return channel_id_; +} +inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* +TextMessage::mutable_channel_id() { + // @@protoc_insertion_point(field_mutable_list:TalkingTreeProto.TextMessage.channel_id) + return &channel_id_; +} + +// repeated uint32 tree_id = 4; +inline int TextMessage::tree_id_size() const { + return tree_id_.size(); +} +inline void TextMessage::clear_tree_id() { + tree_id_.Clear(); +} +inline ::google::protobuf::uint32 TextMessage::tree_id(int index) const { + // @@protoc_insertion_point(field_get:TalkingTreeProto.TextMessage.tree_id) + return tree_id_.Get(index); +} +inline void TextMessage::set_tree_id(int index, ::google::protobuf::uint32 value) { + tree_id_.Set(index, value); + // @@protoc_insertion_point(field_set:TalkingTreeProto.TextMessage.tree_id) +} +inline void TextMessage::add_tree_id(::google::protobuf::uint32 value) { + tree_id_.Add(value); + // @@protoc_insertion_point(field_add:TalkingTreeProto.TextMessage.tree_id) +} +inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& +TextMessage::tree_id() const { + // @@protoc_insertion_point(field_list:TalkingTreeProto.TextMessage.tree_id) + return tree_id_; +} +inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* +TextMessage::mutable_tree_id() { + // @@protoc_insertion_point(field_mutable_list:TalkingTreeProto.TextMessage.tree_id) + return &tree_id_; +} + +// required string message = 5; +inline bool TextMessage::has_message() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +inline void TextMessage::set_has_message() { + _has_bits_[0] |= 0x00000001u; +} +inline void TextMessage::clear_has_message() { + _has_bits_[0] &= ~0x00000001u; +} +inline void TextMessage::clear_message() { + message_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_message(); +} +inline const ::std::string& TextMessage::message() const { + // @@protoc_insertion_point(field_get:TalkingTreeProto.TextMessage.message) + return message_.GetNoArena(); +} +inline void TextMessage::set_message(const ::std::string& value) { + set_has_message(); + message_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:TalkingTreeProto.TextMessage.message) +} +#if LANG_CXX11 +inline void TextMessage::set_message(::std::string&& value) { + set_has_message(); + message_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:TalkingTreeProto.TextMessage.message) +} +#endif +inline void TextMessage::set_message(const char* value) { + GOOGLE_DCHECK(value != NULL); + set_has_message(); + message_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:TalkingTreeProto.TextMessage.message) +} +inline void TextMessage::set_message(const char* value, size_t size) { + set_has_message(); + message_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:TalkingTreeProto.TextMessage.message) +} +inline ::std::string* TextMessage::mutable_message() { + set_has_message(); + // @@protoc_insertion_point(field_mutable:TalkingTreeProto.TextMessage.message) + return message_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline ::std::string* TextMessage::release_message() { + // @@protoc_insertion_point(field_release:TalkingTreeProto.TextMessage.message) + clear_has_message(); + return message_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void TextMessage::set_allocated_message(::std::string* message) { + if (message != NULL) { + set_has_message(); + } else { + clear_has_message(); + } + message_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), message); + // @@protoc_insertion_point(field_set_allocated:TalkingTreeProto.TextMessage.message) +} + +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ +#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS + +// @@protoc_insertion_point(namespace_scope) + + +} // namespace TalkingTreeProto + +// @@protoc_insertion_point(global_scope) + +#endif // PROTOBUF_modules_2ftalkingtree_2fTalkingTree_2eproto__INCLUDED diff --git a/modules/talkingtree/TalkingTree.proto b/modules/talkingtree/TalkingTree.proto index d2eca7a77713..8a10067555c1 100644 --- a/modules/talkingtree/TalkingTree.proto +++ b/modules/talkingtree/TalkingTree.proto @@ -2,3 +2,18 @@ package TalkingTreeProto; option optimize_for = SPEED; +// Used to send and broadcast text messages. +message TextMessage { + // The message sender, identified by its session. + optional uint32 actor = 1; + // Target users for the message, identified by their session. + repeated uint32 session = 2; + // The channels to which the message is sent, identified by their + // channel_ids. + repeated uint32 channel_id = 3; + // The root channels when sending message recursively to several channels, + // identified by their channel_ids. + repeated uint32 tree_id = 4; + // The UTF-8 encoded message. May be HTML if the server allows. + required string message = 5; +} diff --git a/modules/talkingtree/register_types.cpp b/modules/talkingtree/register_types.cpp index 7e7a5f1fef6d..ab08ef05be5a 100644 --- a/modules/talkingtree/register_types.cpp +++ b/modules/talkingtree/register_types.cpp @@ -3,9 +3,10 @@ #include "register_types.h" #include "class_db.h" +#include "talking_tree.h" void register_talkingtree_types() { - + ClassDB::register_class(); } void unregister_talkingtree_types() { diff --git a/modules/talkingtree/talking_tree.cpp b/modules/talkingtree/talking_tree.cpp new file mode 100644 index 000000000000..0c6be7dbaf3f --- /dev/null +++ b/modules/talkingtree/talking_tree.cpp @@ -0,0 +1,10 @@ +/* talking_tree.cpp */ + +#include "talking_tree.h" + + +void TalkingTree::_bind_methods() { +} + +TalkingTree::TalkingTree() { +} diff --git a/modules/talkingtree/talking_tree.h b/modules/talkingtree/talking_tree.h new file mode 100644 index 000000000000..1fc9878e35f2 --- /dev/null +++ b/modules/talkingtree/talking_tree.h @@ -0,0 +1,20 @@ +/* talking_tree.h */ +#ifndef TALKING_TREE_H +#define TALKING_TREE_H + +#include "reference.h" +#include "TalkingTree.pb.h" + +class TalkingTree : public Reference { + GDCLASS(TalkingTree, Reference); + + int count; + +protected: + static void _bind_methods(); + +public: + TalkingTree(); +}; + +#endif From a881d00df472500aa68688ede48998ac87334306 Mon Sep 17 00:00:00 2001 From: hungrymonkey Date: Wed, 25 Oct 2017 22:53:02 -0700 Subject: [PATCH 2/9] fix build errors --- modules/talkingtree/.gitignore | 2 ++ modules/talkingtree/SCsub | 43 +++++++++++++++++++++++---- modules/talkingtree/TalkingTree.proto | 13 ++++++++ modules/talkingtree/config.py | 5 ++-- modules/talkingtree/talking_tree.cpp | 41 +++++++++++++++++++++++++ modules/talkingtree/talking_tree.h | 20 +++++++++---- 6 files changed, 110 insertions(+), 14 deletions(-) diff --git a/modules/talkingtree/.gitignore b/modules/talkingtree/.gitignore index 221ac49db732..6cf1bd31730a 100644 --- a/modules/talkingtree/.gitignore +++ b/modules/talkingtree/.gitignore @@ -1,3 +1,5 @@ *.o *.os *.pyc +*.pb.h +*.pb.cc diff --git a/modules/talkingtree/SCsub b/modules/talkingtree/SCsub index 08e3d65fcd40..ab4db4eb3ca1 100644 --- a/modules/talkingtree/SCsub +++ b/modules/talkingtree/SCsub @@ -1,15 +1,46 @@ # SCsub Import('env') + +import os.path + + env_talkingtree = env.Clone() talkingtree_dir = '#modules/talkingtree/' protobuf_proto = 'TalkingTree.proto' - -protobuf_target = env_talkingtree.Command( 'TalkingTree.pb.cc', \ - protobuf_proto, \ - "protoc --proto_path=. --cpp_out=. $SOURCE") -Depends( env.modules_sources, protobuf_target) -env_talkingtree.add_source_files(env.modules_sources,"*.cpp") +protobuf_suffix = ".proto" +#protobuf_target = env_talkingtree.Command( ['TalkingTree.pb.cc', 'TalkingTree.pb.h'], \ +# protobuf_proto, \ +# "protoc --proto_path=. --cpp_out=. $SOURCE") +#Depends(,protobuf_target ) + +def _protobuf_emitter(target, source, env): + target = [] + for s in source: + src = str(s) + if src.endswith(protobuf_suffix): + p_stem = src[:-len(protobuf_suffix)] + else: + p_stem = src + target.append(p_stem + '.pb.h') + target.append(p_stem + '.pb.cc') + return target, source + +def filter_headers(f_list): + l = [] + for f in f_list: + if os.path.splitext(f.rstr())[1] != '.h': + l.append(f) + return l + +bld = Builder(action="protoc --proto_path=. --cpp_out=. $SOURCE", \ +# suffix = '.pb.cc', \ + src_suffix = [protobuf_suffix], \ + emitter = _protobuf_emitter) +env_talkingtree['BUILDERS']['Protoc'] = bld +protobuf_target = env_talkingtree.Protoc( protobuf_proto ) +sources = Glob("*.cpp")+filter_headers(protobuf_target) +env_talkingtree.add_source_files(env.modules_sources, sources ) env_talkingtree.Append(CXXFLAGS=['-O2', '-std=c++11']) diff --git a/modules/talkingtree/TalkingTree.proto b/modules/talkingtree/TalkingTree.proto index 8a10067555c1..a08ff7ebb96c 100644 --- a/modules/talkingtree/TalkingTree.proto +++ b/modules/talkingtree/TalkingTree.proto @@ -2,6 +2,19 @@ package TalkingTreeProto; option optimize_for = SPEED; + +message Version { + // 2-byte Major, 1-byte Minor and 1-byte Patch version number. + optional uint32 version = 1; + // Client release name. + optional string release = 2; + // Client OS name. + optional string os = 3; + // Client OS version. + optional string os_version = 4; +} + + // Used to send and broadcast text messages. message TextMessage { // The message sender, identified by its session. diff --git a/modules/talkingtree/config.py b/modules/talkingtree/config.py index b39f1d00103b..af243d9c5f49 100644 --- a/modules/talkingtree/config.py +++ b/modules/talkingtree/config.py @@ -1,7 +1,8 @@ # config.py def can_build(platform): - return True + return True def configure(env): - pass + env.Append(LIBS=['protobuf']) + pass diff --git a/modules/talkingtree/talking_tree.cpp b/modules/talkingtree/talking_tree.cpp index 0c6be7dbaf3f..fad5514206a3 100644 --- a/modules/talkingtree/talking_tree.cpp +++ b/modules/talkingtree/talking_tree.cpp @@ -1,10 +1,51 @@ /* talking_tree.cpp */ #include "talking_tree.h" +#include "talking_tree_enum.h" + +#include "TalkingTree.pb.h" void TalkingTree::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_network_peer", "peer"), &TalkingTree::set_network_peer); + ClassDB::bind_method(D_METHOD("is_network_server"), &TalkingTree::is_network_server); + ClassDB::bind_method(D_METHOD("has_network_peer"), &TalkingTree::has_network_peer); } TalkingTree::TalkingTree() { } +void TalkingTree::sendText(String msg) { + TalkingTreeProto::TextMessage txtMsg; +} +bool TalkingTree::is_network_server() const { + + ERR_FAIL_COND_V(!network_peer.is_valid(), false); + return network_peer->is_server(); +} + +bool TalkingTree::has_network_peer() const { + return network_peer.is_valid(); +} + +void TalkingTree::set_network_peer(const Ref &p_network_peer) { + if (network_peer.is_valid()) { + network_peer->disconnect("peer_connected", this, "_network_peer_connected"); + network_peer->disconnect("peer_disconnected", this, "_network_peer_disconnected"); + network_peer->disconnect("connection_succeeded", this, "_connected_to_server"); + network_peer->disconnect("connection_failed", this, "_connection_failed"); + network_peer->disconnect("server_disconnected", this, "_server_disconnected"); + connected_peers.clear(); + last_send_cache_id = 1; + } + + ERR_EXPLAIN("Supplied NetworkedNetworkPeer must be connecting or connected."); + ERR_FAIL_COND(p_network_peer.is_valid() && p_network_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_DISCONNECTED); + network_peer = p_network_peer; + if (network_peer.is_valid()) { + network_peer->connect("peer_connected", this, "_network_peer_connected"); + network_peer->connect("peer_disconnected", this, "_network_peer_disconnected"); + network_peer->connect("connection_succeeded", this, "_connected_to_server"); + network_peer->connect("connection_failed", this, "_connection_failed"); + network_peer->connect("server_disconnected", this, "_server_disconnected"); + } +} diff --git a/modules/talkingtree/talking_tree.h b/modules/talkingtree/talking_tree.h index 1fc9878e35f2..96057a86690d 100644 --- a/modules/talkingtree/talking_tree.h +++ b/modules/talkingtree/talking_tree.h @@ -3,18 +3,26 @@ #define TALKING_TREE_H #include "reference.h" -#include "TalkingTree.pb.h" +#include "io/networked_multiplayer_peer.h" +#include "ustring.h" class TalkingTree : public Reference { - GDCLASS(TalkingTree, Reference); - - int count; + GDCLASS(TalkingTree, Reference); protected: - static void _bind_methods(); + static void _bind_methods(); public: - TalkingTree(); + TalkingTree(); + void set_network_peer(const Ref &p_network_peer); + bool is_network_server() const; + bool has_network_peer() const; + void sendText(String msg); +private: + Set connected_peers; + int last_send_cache_id; + + Ref network_peer; }; #endif From 9d61ba7284cab6fbcca9fafa0ab46aa15d2eb2b6 Mon Sep 17 00:00:00 2001 From: hungrymonkey Date: Wed, 25 Oct 2017 22:54:27 -0700 Subject: [PATCH 3/9] added enum for messages, I fix build errors in the previous commit. I forgot a lib --- modules/talkingtree/talking_tree_enum.h | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 modules/talkingtree/talking_tree_enum.h diff --git a/modules/talkingtree/talking_tree_enum.h b/modules/talkingtree/talking_tree_enum.h new file mode 100644 index 000000000000..7cd574235b63 --- /dev/null +++ b/modules/talkingtree/talking_tree_enum.h @@ -0,0 +1,6 @@ +#pragma once + +enum class PacketType{ + VERSION = 0, + TEXTMESSAGE = 1 +}; From 40c6a5f5b79a674a2e06b6a0bbf564e401ef5253 Mon Sep 17 00:00:00 2001 From: hungrymonkey Date: Thu, 26 Oct 2017 06:02:22 -0700 Subject: [PATCH 4/9] removed pb.h files that were generated and added some lines for sending text. I have added the actual code meant to send for enet etc yet --- modules/talkingtree/TalkingTree.pb.cc | 759 -------------------------- modules/talkingtree/TalkingTree.pb.h | 422 -------------- modules/talkingtree/talking_tree.cpp | 11 + modules/talkingtree/talking_tree.h | 4 +- 4 files changed, 14 insertions(+), 1182 deletions(-) delete mode 100644 modules/talkingtree/TalkingTree.pb.cc delete mode 100644 modules/talkingtree/TalkingTree.pb.h diff --git a/modules/talkingtree/TalkingTree.pb.cc b/modules/talkingtree/TalkingTree.pb.cc deleted file mode 100644 index 594e06737473..000000000000 --- a/modules/talkingtree/TalkingTree.pb.cc +++ /dev/null @@ -1,759 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: modules/talkingtree/TalkingTree.proto - -#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION -#include "modules/talkingtree/TalkingTree.pb.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -// @@protoc_insertion_point(includes) - -namespace TalkingTreeProto { -class TextMessageDefaultTypeInternal { -public: - ::google::protobuf::internal::ExplicitlyConstructed - _instance; -} _TextMessage_default_instance_; - -namespace protobuf_modules_2ftalkingtree_2fTalkingTree_2eproto { - - -namespace { - -::google::protobuf::Metadata file_level_metadata[1]; - -} // namespace - -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTableField - const TableStruct::entries[] GOOGLE_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { - {0, 0, 0, ::google::protobuf::internal::kInvalidMask, 0, 0}, -}; - -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::AuxillaryParseTableField - const TableStruct::aux[] GOOGLE_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { - ::google::protobuf::internal::AuxillaryParseTableField(), -}; -PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTable const - TableStruct::schema[] GOOGLE_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { - { NULL, NULL, 0, -1, -1, -1, -1, NULL, false }, -}; - -const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TextMessage, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TextMessage, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TextMessage, actor_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TextMessage, session_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TextMessage, channel_id_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TextMessage, tree_id_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TextMessage, message_), - 1, - ~0u, - ~0u, - ~0u, - 0, -}; -static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { - { 0, 10, sizeof(TextMessage)}, -}; - -static ::google::protobuf::Message const * const file_default_instances[] = { - reinterpret_cast(&_TextMessage_default_instance_), -}; - -namespace { - -void protobuf_AssignDescriptors() { - AddDescriptors(); - ::google::protobuf::MessageFactory* factory = NULL; - AssignDescriptors( - "modules/talkingtree/TalkingTree.proto", schemas, file_default_instances, TableStruct::offsets, factory, - file_level_metadata, NULL, NULL); -} - -void protobuf_AssignDescriptorsOnce() { - static GOOGLE_PROTOBUF_DECLARE_ONCE(once); - ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); -} - -void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; -void protobuf_RegisterTypes(const ::std::string&) { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1); -} - -} // namespace -void TableStruct::InitDefaultsImpl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - ::google::protobuf::internal::InitProtobufDefaults(); - _TextMessage_default_instance_._instance.DefaultConstruct(); - ::google::protobuf::internal::OnShutdownDestroyMessage( - &_TextMessage_default_instance_);} - -void InitDefaults() { - static GOOGLE_PROTOBUF_DECLARE_ONCE(once); - ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); -} -namespace { -void AddDescriptorsImpl() { - InitDefaults(); - static const char descriptor[] GOOGLE_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { - "\n%modules/talkingtree/TalkingTree.proto\022" - "\020TalkingTreeProto\"c\n\013TextMessage\022\r\n\005acto" - "r\030\001 \001(\r\022\017\n\007session\030\002 \003(\r\022\022\n\nchannel_id\030\003" - " \003(\r\022\017\n\007tree_id\030\004 \003(\r\022\017\n\007message\030\005 \002(\tB\002" - "H\001" - }; - ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - descriptor, 162); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( - "modules/talkingtree/TalkingTree.proto", &protobuf_RegisterTypes); -} -} // anonymous namespace - -void AddDescriptors() { - static GOOGLE_PROTOBUF_DECLARE_ONCE(once); - ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); -} -// Force AddDescriptors() to be called at dynamic initialization time. -struct StaticDescriptorInitializer { - StaticDescriptorInitializer() { - AddDescriptors(); - } -} static_descriptor_initializer; - -} // namespace protobuf_modules_2ftalkingtree_2fTalkingTree_2eproto - - -// =================================================================== - -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int TextMessage::kActorFieldNumber; -const int TextMessage::kSessionFieldNumber; -const int TextMessage::kChannelIdFieldNumber; -const int TextMessage::kTreeIdFieldNumber; -const int TextMessage::kMessageFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - -TextMessage::TextMessage() - : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_modules_2ftalkingtree_2fTalkingTree_2eproto::InitDefaults(); - } - SharedCtor(); - // @@protoc_insertion_point(constructor:TalkingTreeProto.TextMessage) -} -TextMessage::TextMessage(const TextMessage& from) - : ::google::protobuf::Message(), - _internal_metadata_(NULL), - _has_bits_(from._has_bits_), - _cached_size_(0), - session_(from.session_), - channel_id_(from.channel_id_), - tree_id_(from.tree_id_) { - _internal_metadata_.MergeFrom(from._internal_metadata_); - message_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (from.has_message()) { - message_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.message_); - } - actor_ = from.actor_; - // @@protoc_insertion_point(copy_constructor:TalkingTreeProto.TextMessage) -} - -void TextMessage::SharedCtor() { - _cached_size_ = 0; - message_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - actor_ = 0u; -} - -TextMessage::~TextMessage() { - // @@protoc_insertion_point(destructor:TalkingTreeProto.TextMessage) - SharedDtor(); -} - -void TextMessage::SharedDtor() { - message_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} - -void TextMessage::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* TextMessage::descriptor() { - protobuf_modules_2ftalkingtree_2fTalkingTree_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_modules_2ftalkingtree_2fTalkingTree_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; -} - -const TextMessage& TextMessage::default_instance() { - protobuf_modules_2ftalkingtree_2fTalkingTree_2eproto::InitDefaults(); - return *internal_default_instance(); -} - -TextMessage* TextMessage::New(::google::protobuf::Arena* arena) const { - TextMessage* n = new TextMessage; - if (arena != NULL) { - arena->Own(n); - } - return n; -} - -void TextMessage::Clear() { -// @@protoc_insertion_point(message_clear_start:TalkingTreeProto.TextMessage) - ::google::protobuf::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - session_.Clear(); - channel_id_.Clear(); - tree_id_.Clear(); - if (has_message()) { - GOOGLE_DCHECK(!message_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); - (*message_.UnsafeRawStringPointer())->clear(); - } - actor_ = 0u; - _has_bits_.Clear(); - _internal_metadata_.Clear(); -} - -bool TextMessage::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure - ::google::protobuf::uint32 tag; - // @@protoc_insertion_point(parse_start:TalkingTreeProto.TextMessage) - for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); - tag = p.first; - if (!p.second) goto handle_unusual; - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional uint32 actor = 1; - case 1: { - if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) { - set_has_actor(); - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( - input, &actor_))); - } else { - goto handle_unusual; - } - break; - } - - // repeated uint32 session = 2; - case 2: { - if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) { - DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< - ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( - 1, 16u, input, this->mutable_session()))); - } else if ( - static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) { - DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< - ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( - input, this->mutable_session()))); - } else { - goto handle_unusual; - } - break; - } - - // repeated uint32 channel_id = 3; - case 3: { - if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(24u /* 24 & 0xFF */)) { - DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< - ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( - 1, 24u, input, this->mutable_channel_id()))); - } else if ( - static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) { - DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< - ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( - input, this->mutable_channel_id()))); - } else { - goto handle_unusual; - } - break; - } - - // repeated uint32 tree_id = 4; - case 4: { - if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(32u /* 32 & 0xFF */)) { - DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< - ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( - 1, 32u, input, this->mutable_tree_id()))); - } else if ( - static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(34u /* 34 & 0xFF */)) { - DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< - ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( - input, this->mutable_tree_id()))); - } else { - goto handle_unusual; - } - break; - } - - // required string message = 5; - case 5: { - if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(42u /* 42 & 0xFF */)) { - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_message())); - ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->message().data(), static_cast(this->message().length()), - ::google::protobuf::internal::WireFormat::PARSE, - "TalkingTreeProto.TextMessage.message"); - } else { - goto handle_unusual; - } - break; - } - - default: { - handle_unusual: - if (tag == 0) { - goto success; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, _internal_metadata_.mutable_unknown_fields())); - break; - } - } - } -success: - // @@protoc_insertion_point(parse_success:TalkingTreeProto.TextMessage) - return true; -failure: - // @@protoc_insertion_point(parse_failure:TalkingTreeProto.TextMessage) - return false; -#undef DO_ -} - -void TextMessage::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // @@protoc_insertion_point(serialize_start:TalkingTreeProto.TextMessage) - ::google::protobuf::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - // optional uint32 actor = 1; - if (cached_has_bits & 0x00000002u) { - ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->actor(), output); - } - - // repeated uint32 session = 2; - for (int i = 0, n = this->session_size(); i < n; i++) { - ::google::protobuf::internal::WireFormatLite::WriteUInt32( - 2, this->session(i), output); - } - - // repeated uint32 channel_id = 3; - for (int i = 0, n = this->channel_id_size(); i < n; i++) { - ::google::protobuf::internal::WireFormatLite::WriteUInt32( - 3, this->channel_id(i), output); - } - - // repeated uint32 tree_id = 4; - for (int i = 0, n = this->tree_id_size(); i < n; i++) { - ::google::protobuf::internal::WireFormatLite::WriteUInt32( - 4, this->tree_id(i), output); - } - - // required string message = 5; - if (cached_has_bits & 0x00000001u) { - ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->message().data(), static_cast(this->message().length()), - ::google::protobuf::internal::WireFormat::SERIALIZE, - "TalkingTreeProto.TextMessage.message"); - ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( - 5, this->message(), output); - } - - if (_internal_metadata_.have_unknown_fields()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - _internal_metadata_.unknown_fields(), output); - } - // @@protoc_insertion_point(serialize_end:TalkingTreeProto.TextMessage) -} - -::google::protobuf::uint8* TextMessage::InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused - // @@protoc_insertion_point(serialize_to_array_start:TalkingTreeProto.TextMessage) - ::google::protobuf::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - // optional uint32 actor = 1; - if (cached_has_bits & 0x00000002u) { - target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->actor(), target); - } - - // repeated uint32 session = 2; - target = ::google::protobuf::internal::WireFormatLite:: - WriteUInt32ToArray(2, this->session_, target); - - // repeated uint32 channel_id = 3; - target = ::google::protobuf::internal::WireFormatLite:: - WriteUInt32ToArray(3, this->channel_id_, target); - - // repeated uint32 tree_id = 4; - target = ::google::protobuf::internal::WireFormatLite:: - WriteUInt32ToArray(4, this->tree_id_, target); - - // required string message = 5; - if (cached_has_bits & 0x00000001u) { - ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->message().data(), static_cast(this->message().length()), - ::google::protobuf::internal::WireFormat::SERIALIZE, - "TalkingTreeProto.TextMessage.message"); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 5, this->message(), target); - } - - if (_internal_metadata_.have_unknown_fields()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields(), target); - } - // @@protoc_insertion_point(serialize_to_array_end:TalkingTreeProto.TextMessage) - return target; -} - -size_t TextMessage::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:TalkingTreeProto.TextMessage) - size_t total_size = 0; - - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - _internal_metadata_.unknown_fields()); - } - // required string message = 5; - if (has_message()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->message()); - } - // repeated uint32 session = 2; - { - size_t data_size = ::google::protobuf::internal::WireFormatLite:: - UInt32Size(this->session_); - total_size += 1 * - ::google::protobuf::internal::FromIntSize(this->session_size()); - total_size += data_size; - } - - // repeated uint32 channel_id = 3; - { - size_t data_size = ::google::protobuf::internal::WireFormatLite:: - UInt32Size(this->channel_id_); - total_size += 1 * - ::google::protobuf::internal::FromIntSize(this->channel_id_size()); - total_size += data_size; - } - - // repeated uint32 tree_id = 4; - { - size_t data_size = ::google::protobuf::internal::WireFormatLite:: - UInt32Size(this->tree_id_); - total_size += 1 * - ::google::protobuf::internal::FromIntSize(this->tree_id_size()); - total_size += data_size; - } - - // optional uint32 actor = 1; - if (has_actor()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::UInt32Size( - this->actor()); - } - - int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = cached_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void TextMessage::MergeFrom(const ::google::protobuf::Message& from) { -// @@protoc_insertion_point(generalized_merge_from_start:TalkingTreeProto.TextMessage) - GOOGLE_DCHECK_NE(&from, this); - const TextMessage* source = - ::google::protobuf::internal::DynamicCastToGenerated( - &from); - if (source == NULL) { - // @@protoc_insertion_point(generalized_merge_from_cast_fail:TalkingTreeProto.TextMessage) - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - // @@protoc_insertion_point(generalized_merge_from_cast_success:TalkingTreeProto.TextMessage) - MergeFrom(*source); - } -} - -void TextMessage::MergeFrom(const TextMessage& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:TalkingTreeProto.TextMessage) - GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom(from._internal_metadata_); - ::google::protobuf::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - session_.MergeFrom(from.session_); - channel_id_.MergeFrom(from.channel_id_); - tree_id_.MergeFrom(from.tree_id_); - cached_has_bits = from._has_bits_[0]; - if (cached_has_bits & 3u) { - if (cached_has_bits & 0x00000001u) { - set_has_message(); - message_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.message_); - } - if (cached_has_bits & 0x00000002u) { - actor_ = from.actor_; - } - _has_bits_[0] |= cached_has_bits; - } -} - -void TextMessage::CopyFrom(const ::google::protobuf::Message& from) { -// @@protoc_insertion_point(generalized_copy_from_start:TalkingTreeProto.TextMessage) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void TextMessage::CopyFrom(const TextMessage& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:TalkingTreeProto.TextMessage) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool TextMessage::IsInitialized() const { - if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false; - return true; -} - -void TextMessage::Swap(TextMessage* other) { - if (other == this) return; - InternalSwap(other); -} -void TextMessage::InternalSwap(TextMessage* other) { - using std::swap; - session_.InternalSwap(&other->session_); - channel_id_.InternalSwap(&other->channel_id_); - tree_id_.InternalSwap(&other->tree_id_); - message_.Swap(&other->message_); - swap(actor_, other->actor_); - swap(_has_bits_[0], other->_has_bits_[0]); - _internal_metadata_.Swap(&other->_internal_metadata_); - swap(_cached_size_, other->_cached_size_); -} - -::google::protobuf::Metadata TextMessage::GetMetadata() const { - protobuf_modules_2ftalkingtree_2fTalkingTree_2eproto::protobuf_AssignDescriptorsOnce(); - return protobuf_modules_2ftalkingtree_2fTalkingTree_2eproto::file_level_metadata[kIndexInFileMessages]; -} - -#if PROTOBUF_INLINE_NOT_IN_HEADERS -// TextMessage - -// optional uint32 actor = 1; -bool TextMessage::has_actor() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void TextMessage::set_has_actor() { - _has_bits_[0] |= 0x00000002u; -} -void TextMessage::clear_has_actor() { - _has_bits_[0] &= ~0x00000002u; -} -void TextMessage::clear_actor() { - actor_ = 0u; - clear_has_actor(); -} -::google::protobuf::uint32 TextMessage::actor() const { - // @@protoc_insertion_point(field_get:TalkingTreeProto.TextMessage.actor) - return actor_; -} -void TextMessage::set_actor(::google::protobuf::uint32 value) { - set_has_actor(); - actor_ = value; - // @@protoc_insertion_point(field_set:TalkingTreeProto.TextMessage.actor) -} - -// repeated uint32 session = 2; -int TextMessage::session_size() const { - return session_.size(); -} -void TextMessage::clear_session() { - session_.Clear(); -} -::google::protobuf::uint32 TextMessage::session(int index) const { - // @@protoc_insertion_point(field_get:TalkingTreeProto.TextMessage.session) - return session_.Get(index); -} -void TextMessage::set_session(int index, ::google::protobuf::uint32 value) { - session_.Set(index, value); - // @@protoc_insertion_point(field_set:TalkingTreeProto.TextMessage.session) -} -void TextMessage::add_session(::google::protobuf::uint32 value) { - session_.Add(value); - // @@protoc_insertion_point(field_add:TalkingTreeProto.TextMessage.session) -} -const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& -TextMessage::session() const { - // @@protoc_insertion_point(field_list:TalkingTreeProto.TextMessage.session) - return session_; -} -::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* -TextMessage::mutable_session() { - // @@protoc_insertion_point(field_mutable_list:TalkingTreeProto.TextMessage.session) - return &session_; -} - -// repeated uint32 channel_id = 3; -int TextMessage::channel_id_size() const { - return channel_id_.size(); -} -void TextMessage::clear_channel_id() { - channel_id_.Clear(); -} -::google::protobuf::uint32 TextMessage::channel_id(int index) const { - // @@protoc_insertion_point(field_get:TalkingTreeProto.TextMessage.channel_id) - return channel_id_.Get(index); -} -void TextMessage::set_channel_id(int index, ::google::protobuf::uint32 value) { - channel_id_.Set(index, value); - // @@protoc_insertion_point(field_set:TalkingTreeProto.TextMessage.channel_id) -} -void TextMessage::add_channel_id(::google::protobuf::uint32 value) { - channel_id_.Add(value); - // @@protoc_insertion_point(field_add:TalkingTreeProto.TextMessage.channel_id) -} -const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& -TextMessage::channel_id() const { - // @@protoc_insertion_point(field_list:TalkingTreeProto.TextMessage.channel_id) - return channel_id_; -} -::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* -TextMessage::mutable_channel_id() { - // @@protoc_insertion_point(field_mutable_list:TalkingTreeProto.TextMessage.channel_id) - return &channel_id_; -} - -// repeated uint32 tree_id = 4; -int TextMessage::tree_id_size() const { - return tree_id_.size(); -} -void TextMessage::clear_tree_id() { - tree_id_.Clear(); -} -::google::protobuf::uint32 TextMessage::tree_id(int index) const { - // @@protoc_insertion_point(field_get:TalkingTreeProto.TextMessage.tree_id) - return tree_id_.Get(index); -} -void TextMessage::set_tree_id(int index, ::google::protobuf::uint32 value) { - tree_id_.Set(index, value); - // @@protoc_insertion_point(field_set:TalkingTreeProto.TextMessage.tree_id) -} -void TextMessage::add_tree_id(::google::protobuf::uint32 value) { - tree_id_.Add(value); - // @@protoc_insertion_point(field_add:TalkingTreeProto.TextMessage.tree_id) -} -const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& -TextMessage::tree_id() const { - // @@protoc_insertion_point(field_list:TalkingTreeProto.TextMessage.tree_id) - return tree_id_; -} -::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* -TextMessage::mutable_tree_id() { - // @@protoc_insertion_point(field_mutable_list:TalkingTreeProto.TextMessage.tree_id) - return &tree_id_; -} - -// required string message = 5; -bool TextMessage::has_message() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void TextMessage::set_has_message() { - _has_bits_[0] |= 0x00000001u; -} -void TextMessage::clear_has_message() { - _has_bits_[0] &= ~0x00000001u; -} -void TextMessage::clear_message() { - message_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_message(); -} -const ::std::string& TextMessage::message() const { - // @@protoc_insertion_point(field_get:TalkingTreeProto.TextMessage.message) - return message_.GetNoArena(); -} -void TextMessage::set_message(const ::std::string& value) { - set_has_message(); - message_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:TalkingTreeProto.TextMessage.message) -} -#if LANG_CXX11 -void TextMessage::set_message(::std::string&& value) { - set_has_message(); - message_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:TalkingTreeProto.TextMessage.message) -} -#endif -void TextMessage::set_message(const char* value) { - GOOGLE_DCHECK(value != NULL); - set_has_message(); - message_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); - // @@protoc_insertion_point(field_set_char:TalkingTreeProto.TextMessage.message) -} -void TextMessage::set_message(const char* value, size_t size) { - set_has_message(); - message_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); - // @@protoc_insertion_point(field_set_pointer:TalkingTreeProto.TextMessage.message) -} -::std::string* TextMessage::mutable_message() { - set_has_message(); - // @@protoc_insertion_point(field_mutable:TalkingTreeProto.TextMessage.message) - return message_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::std::string* TextMessage::release_message() { - // @@protoc_insertion_point(field_release:TalkingTreeProto.TextMessage.message) - clear_has_message(); - return message_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -void TextMessage::set_allocated_message(::std::string* message) { - if (message != NULL) { - set_has_message(); - } else { - clear_has_message(); - } - message_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), message); - // @@protoc_insertion_point(field_set_allocated:TalkingTreeProto.TextMessage.message) -} - -#endif // PROTOBUF_INLINE_NOT_IN_HEADERS - -// @@protoc_insertion_point(namespace_scope) - -} // namespace TalkingTreeProto - -// @@protoc_insertion_point(global_scope) diff --git a/modules/talkingtree/TalkingTree.pb.h b/modules/talkingtree/TalkingTree.pb.h deleted file mode 100644 index 6c13ac59376b..000000000000 --- a/modules/talkingtree/TalkingTree.pb.h +++ /dev/null @@ -1,422 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: modules/talkingtree/TalkingTree.proto - -#ifndef PROTOBUF_modules_2ftalkingtree_2fTalkingTree_2eproto__INCLUDED -#define PROTOBUF_modules_2ftalkingtree_2fTalkingTree_2eproto__INCLUDED - -#include - -#include - -#if GOOGLE_PROTOBUF_VERSION < 3004000 -#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 3004000 < GOOGLE_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 // IWYU pragma: export -#include // IWYU pragma: export -#include -// @@protoc_insertion_point(includes) -namespace TalkingTreeProto { -class TextMessage; -class TextMessageDefaultTypeInternal; -extern TextMessageDefaultTypeInternal _TextMessage_default_instance_; -} // namespace TalkingTreeProto - -namespace TalkingTreeProto { - -namespace protobuf_modules_2ftalkingtree_2fTalkingTree_2eproto { -// Internal implementation detail -- do not call these. -struct TableStruct { - static const ::google::protobuf::internal::ParseTableField entries[]; - static const ::google::protobuf::internal::AuxillaryParseTableField aux[]; - static const ::google::protobuf::internal::ParseTable schema[]; - static const ::google::protobuf::uint32 offsets[]; - static const ::google::protobuf::internal::FieldMetadata field_metadata[]; - static const ::google::protobuf::internal::SerializationTable serialization_table[]; - static void InitDefaultsImpl(); -}; -void AddDescriptors(); -void InitDefaults(); -} // namespace protobuf_modules_2ftalkingtree_2fTalkingTree_2eproto - -// =================================================================== - -class TextMessage : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:TalkingTreeProto.TextMessage) */ { - public: - TextMessage(); - virtual ~TextMessage(); - - TextMessage(const TextMessage& from); - - inline TextMessage& operator=(const TextMessage& from) { - CopyFrom(from); - return *this; - } - #if LANG_CXX11 - TextMessage(TextMessage&& from) noexcept - : TextMessage() { - *this = ::std::move(from); - } - - inline TextMessage& operator=(TextMessage&& from) noexcept { - if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { - if (this != &from) InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - #endif - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields(); - } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields(); - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const TextMessage& default_instance(); - - static inline const TextMessage* internal_default_instance() { - return reinterpret_cast( - &_TextMessage_default_instance_); - } - static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = - 0; - - void Swap(TextMessage* other); - friend void swap(TextMessage& a, TextMessage& b) { - a.Swap(&b); - } - - // implements Message ---------------------------------------------- - - inline TextMessage* New() const PROTOBUF_FINAL { return New(NULL); } - - TextMessage* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; - void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; - void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; - void CopyFrom(const TextMessage& from); - void MergeFrom(const TextMessage& from); - void Clear() PROTOBUF_FINAL; - bool IsInitialized() const PROTOBUF_FINAL; - - size_t ByteSizeLong() const PROTOBUF_FINAL; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; - ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; - int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const PROTOBUF_FINAL; - void InternalSwap(TextMessage* other); - private: - inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return NULL; - } - inline void* MaybeArenaPtr() const { - return NULL; - } - public: - - ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // repeated uint32 session = 2; - int session_size() const; - void clear_session(); - static const int kSessionFieldNumber = 2; - ::google::protobuf::uint32 session(int index) const; - void set_session(int index, ::google::protobuf::uint32 value); - void add_session(::google::protobuf::uint32 value); - const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& - session() const; - ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* - mutable_session(); - - // repeated uint32 channel_id = 3; - int channel_id_size() const; - void clear_channel_id(); - static const int kChannelIdFieldNumber = 3; - ::google::protobuf::uint32 channel_id(int index) const; - void set_channel_id(int index, ::google::protobuf::uint32 value); - void add_channel_id(::google::protobuf::uint32 value); - const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& - channel_id() const; - ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* - mutable_channel_id(); - - // repeated uint32 tree_id = 4; - int tree_id_size() const; - void clear_tree_id(); - static const int kTreeIdFieldNumber = 4; - ::google::protobuf::uint32 tree_id(int index) const; - void set_tree_id(int index, ::google::protobuf::uint32 value); - void add_tree_id(::google::protobuf::uint32 value); - const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& - tree_id() const; - ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* - mutable_tree_id(); - - // required string message = 5; - bool has_message() const; - void clear_message(); - static const int kMessageFieldNumber = 5; - const ::std::string& message() const; - void set_message(const ::std::string& value); - #if LANG_CXX11 - void set_message(::std::string&& value); - #endif - void set_message(const char* value); - void set_message(const char* value, size_t size); - ::std::string* mutable_message(); - ::std::string* release_message(); - void set_allocated_message(::std::string* message); - - // optional uint32 actor = 1; - bool has_actor() const; - void clear_actor(); - static const int kActorFieldNumber = 1; - ::google::protobuf::uint32 actor() const; - void set_actor(::google::protobuf::uint32 value); - - // @@protoc_insertion_point(class_scope:TalkingTreeProto.TextMessage) - private: - void set_has_actor(); - void clear_has_actor(); - void set_has_message(); - void clear_has_message(); - - ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::internal::HasBits<1> _has_bits_; - mutable int _cached_size_; - ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > session_; - ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > channel_id_; - ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > tree_id_; - ::google::protobuf::internal::ArenaStringPtr message_; - ::google::protobuf::uint32 actor_; - friend struct protobuf_modules_2ftalkingtree_2fTalkingTree_2eproto::TableStruct; -}; -// =================================================================== - - -// =================================================================== - -#if !PROTOBUF_INLINE_NOT_IN_HEADERS -#ifdef __GNUC__ - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wstrict-aliasing" -#endif // __GNUC__ -// TextMessage - -// optional uint32 actor = 1; -inline bool TextMessage::has_actor() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -inline void TextMessage::set_has_actor() { - _has_bits_[0] |= 0x00000002u; -} -inline void TextMessage::clear_has_actor() { - _has_bits_[0] &= ~0x00000002u; -} -inline void TextMessage::clear_actor() { - actor_ = 0u; - clear_has_actor(); -} -inline ::google::protobuf::uint32 TextMessage::actor() const { - // @@protoc_insertion_point(field_get:TalkingTreeProto.TextMessage.actor) - return actor_; -} -inline void TextMessage::set_actor(::google::protobuf::uint32 value) { - set_has_actor(); - actor_ = value; - // @@protoc_insertion_point(field_set:TalkingTreeProto.TextMessage.actor) -} - -// repeated uint32 session = 2; -inline int TextMessage::session_size() const { - return session_.size(); -} -inline void TextMessage::clear_session() { - session_.Clear(); -} -inline ::google::protobuf::uint32 TextMessage::session(int index) const { - // @@protoc_insertion_point(field_get:TalkingTreeProto.TextMessage.session) - return session_.Get(index); -} -inline void TextMessage::set_session(int index, ::google::protobuf::uint32 value) { - session_.Set(index, value); - // @@protoc_insertion_point(field_set:TalkingTreeProto.TextMessage.session) -} -inline void TextMessage::add_session(::google::protobuf::uint32 value) { - session_.Add(value); - // @@protoc_insertion_point(field_add:TalkingTreeProto.TextMessage.session) -} -inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& -TextMessage::session() const { - // @@protoc_insertion_point(field_list:TalkingTreeProto.TextMessage.session) - return session_; -} -inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* -TextMessage::mutable_session() { - // @@protoc_insertion_point(field_mutable_list:TalkingTreeProto.TextMessage.session) - return &session_; -} - -// repeated uint32 channel_id = 3; -inline int TextMessage::channel_id_size() const { - return channel_id_.size(); -} -inline void TextMessage::clear_channel_id() { - channel_id_.Clear(); -} -inline ::google::protobuf::uint32 TextMessage::channel_id(int index) const { - // @@protoc_insertion_point(field_get:TalkingTreeProto.TextMessage.channel_id) - return channel_id_.Get(index); -} -inline void TextMessage::set_channel_id(int index, ::google::protobuf::uint32 value) { - channel_id_.Set(index, value); - // @@protoc_insertion_point(field_set:TalkingTreeProto.TextMessage.channel_id) -} -inline void TextMessage::add_channel_id(::google::protobuf::uint32 value) { - channel_id_.Add(value); - // @@protoc_insertion_point(field_add:TalkingTreeProto.TextMessage.channel_id) -} -inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& -TextMessage::channel_id() const { - // @@protoc_insertion_point(field_list:TalkingTreeProto.TextMessage.channel_id) - return channel_id_; -} -inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* -TextMessage::mutable_channel_id() { - // @@protoc_insertion_point(field_mutable_list:TalkingTreeProto.TextMessage.channel_id) - return &channel_id_; -} - -// repeated uint32 tree_id = 4; -inline int TextMessage::tree_id_size() const { - return tree_id_.size(); -} -inline void TextMessage::clear_tree_id() { - tree_id_.Clear(); -} -inline ::google::protobuf::uint32 TextMessage::tree_id(int index) const { - // @@protoc_insertion_point(field_get:TalkingTreeProto.TextMessage.tree_id) - return tree_id_.Get(index); -} -inline void TextMessage::set_tree_id(int index, ::google::protobuf::uint32 value) { - tree_id_.Set(index, value); - // @@protoc_insertion_point(field_set:TalkingTreeProto.TextMessage.tree_id) -} -inline void TextMessage::add_tree_id(::google::protobuf::uint32 value) { - tree_id_.Add(value); - // @@protoc_insertion_point(field_add:TalkingTreeProto.TextMessage.tree_id) -} -inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& -TextMessage::tree_id() const { - // @@protoc_insertion_point(field_list:TalkingTreeProto.TextMessage.tree_id) - return tree_id_; -} -inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* -TextMessage::mutable_tree_id() { - // @@protoc_insertion_point(field_mutable_list:TalkingTreeProto.TextMessage.tree_id) - return &tree_id_; -} - -// required string message = 5; -inline bool TextMessage::has_message() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void TextMessage::set_has_message() { - _has_bits_[0] |= 0x00000001u; -} -inline void TextMessage::clear_has_message() { - _has_bits_[0] &= ~0x00000001u; -} -inline void TextMessage::clear_message() { - message_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_message(); -} -inline const ::std::string& TextMessage::message() const { - // @@protoc_insertion_point(field_get:TalkingTreeProto.TextMessage.message) - return message_.GetNoArena(); -} -inline void TextMessage::set_message(const ::std::string& value) { - set_has_message(); - message_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:TalkingTreeProto.TextMessage.message) -} -#if LANG_CXX11 -inline void TextMessage::set_message(::std::string&& value) { - set_has_message(); - message_.SetNoArena( - &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:TalkingTreeProto.TextMessage.message) -} -#endif -inline void TextMessage::set_message(const char* value) { - GOOGLE_DCHECK(value != NULL); - set_has_message(); - message_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); - // @@protoc_insertion_point(field_set_char:TalkingTreeProto.TextMessage.message) -} -inline void TextMessage::set_message(const char* value, size_t size) { - set_has_message(); - message_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); - // @@protoc_insertion_point(field_set_pointer:TalkingTreeProto.TextMessage.message) -} -inline ::std::string* TextMessage::mutable_message() { - set_has_message(); - // @@protoc_insertion_point(field_mutable:TalkingTreeProto.TextMessage.message) - return message_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -inline ::std::string* TextMessage::release_message() { - // @@protoc_insertion_point(field_release:TalkingTreeProto.TextMessage.message) - clear_has_message(); - return message_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -inline void TextMessage::set_allocated_message(::std::string* message) { - if (message != NULL) { - set_has_message(); - } else { - clear_has_message(); - } - message_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), message); - // @@protoc_insertion_point(field_set_allocated:TalkingTreeProto.TextMessage.message) -} - -#ifdef __GNUC__ - #pragma GCC diagnostic pop -#endif // __GNUC__ -#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS - -// @@protoc_insertion_point(namespace_scope) - - -} // namespace TalkingTreeProto - -// @@protoc_insertion_point(global_scope) - -#endif // PROTOBUF_modules_2ftalkingtree_2fTalkingTree_2eproto__INCLUDED diff --git a/modules/talkingtree/talking_tree.cpp b/modules/talkingtree/talking_tree.cpp index fad5514206a3..219c23a961bd 100644 --- a/modules/talkingtree/talking_tree.cpp +++ b/modules/talkingtree/talking_tree.cpp @@ -4,6 +4,7 @@ #include "talking_tree_enum.h" #include "TalkingTree.pb.h" +#include "io/marshalls.h" void TalkingTree::_bind_methods() { @@ -16,7 +17,17 @@ TalkingTree::TalkingTree() { } void TalkingTree::sendText(String msg) { TalkingTreeProto::TextMessage txtMsg; + CharString m = msg.utf8(); + txtMsg.set_message(m.get_data(), m.length()); } +void TalkingTree::sendPacket(PacketType type, google::protobuf::Message &message){ + Vector packet; + packet.resize(1 + 4 + message.ByteSize()); + packet[0] = (uint8_t)type; + encode_uint32(message.ByteSize(), &packet[1]); + message.SerializeToArray( &packet[5], message.ByteSize()); +} + bool TalkingTree::is_network_server() const { ERR_FAIL_COND_V(!network_peer.is_valid(), false); diff --git a/modules/talkingtree/talking_tree.h b/modules/talkingtree/talking_tree.h index 96057a86690d..96d6356cb402 100644 --- a/modules/talkingtree/talking_tree.h +++ b/modules/talkingtree/talking_tree.h @@ -5,6 +5,8 @@ #include "reference.h" #include "io/networked_multiplayer_peer.h" #include "ustring.h" +#include "talking_tree_enum.h" +#include class TalkingTree : public Reference { GDCLASS(TalkingTree, Reference); @@ -21,8 +23,8 @@ class TalkingTree : public Reference { private: Set connected_peers; int last_send_cache_id; - Ref network_peer; + void sendPacket(PacketType type, google::protobuf::Message &message); }; #endif From ab9cf8f5437adb6fa3df0f24850a3e1094681eb2 Mon Sep 17 00:00:00 2001 From: hungrymonkey Date: Thu, 26 Oct 2017 17:34:58 -0700 Subject: [PATCH 5/9] add files for merge --- modules/talkingtree/TalkingTree.proto | 5 +++++ modules/talkingtree/talking_tree.cpp | 17 +++++++++++++++-- modules/talkingtree/talking_tree.h | 6 ++++-- modules/talkingtree/talking_tree_enum.h | 3 ++- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/modules/talkingtree/TalkingTree.proto b/modules/talkingtree/TalkingTree.proto index a08ff7ebb96c..0d1f7927d1c3 100644 --- a/modules/talkingtree/TalkingTree.proto +++ b/modules/talkingtree/TalkingTree.proto @@ -30,3 +30,8 @@ message TextMessage { // The UTF-8 encoded message. May be HTML if the server allows. required string message = 5; } + +message UDPTunnel { + // Not used. + required bytes packet = 1; +} diff --git a/modules/talkingtree/talking_tree.cpp b/modules/talkingtree/talking_tree.cpp index 219c23a961bd..e07593481ece 100644 --- a/modules/talkingtree/talking_tree.cpp +++ b/modules/talkingtree/talking_tree.cpp @@ -11,22 +11,27 @@ void TalkingTree::_bind_methods() { ClassDB::bind_method(D_METHOD("set_network_peer", "peer"), &TalkingTree::set_network_peer); ClassDB::bind_method(D_METHOD("is_network_server"), &TalkingTree::is_network_server); ClassDB::bind_method(D_METHOD("has_network_peer"), &TalkingTree::has_network_peer); + ClassDB::bind_method(D_METHOD("get_network_connected_peers"), &TalkingTree::get_network_connected_peers); + } TalkingTree::TalkingTree() { } -void TalkingTree::sendText(String msg) { +void TalkingTree::send_text(String msg) { TalkingTreeProto::TextMessage txtMsg; CharString m = msg.utf8(); txtMsg.set_message(m.get_data(), m.length()); } -void TalkingTree::sendPacket(PacketType type, google::protobuf::Message &message){ +void TalkingTree::_send_packet(PacketType type, google::protobuf::Message &message){ Vector packet; packet.resize(1 + 4 + message.ByteSize()); packet[0] = (uint8_t)type; encode_uint32(message.ByteSize(), &packet[1]); message.SerializeToArray( &packet[5], message.ByteSize()); } +void TalkingTree::_serialize_packet(int p_from, const uint8_t *p_packet, int p_packet_len) { + uint8_t packet_type = p_packet[0]; +} bool TalkingTree::is_network_server() const { @@ -60,3 +65,11 @@ void TalkingTree::set_network_peer(const Ref &p_networ network_peer->connect("server_disconnected", this, "_server_disconnected"); } } +Vector TalkingTree::get_network_connected_peers() const { + ERR_FAIL_COND_V(!network_peer.is_valid(), Vector()); + Vector ret; + for (Set::Element *E = connected_peers.front(); E; E = E->next()) { + ret.push_back(E->get()); + } + return ret; +} diff --git a/modules/talkingtree/talking_tree.h b/modules/talkingtree/talking_tree.h index 96d6356cb402..b01592da8a67 100644 --- a/modules/talkingtree/talking_tree.h +++ b/modules/talkingtree/talking_tree.h @@ -17,14 +17,16 @@ class TalkingTree : public Reference { public: TalkingTree(); void set_network_peer(const Ref &p_network_peer); + Vector get_network_connected_peers() const; bool is_network_server() const; bool has_network_peer() const; - void sendText(String msg); + void send_text(String msg); private: Set connected_peers; int last_send_cache_id; Ref network_peer; - void sendPacket(PacketType type, google::protobuf::Message &message); + void _send_packet(PacketType type, google::protobuf::Message &message); + void _serialize_packet(int p_from, const uint8_t *p_packet, int p_packet_len); }; #endif diff --git a/modules/talkingtree/talking_tree_enum.h b/modules/talkingtree/talking_tree_enum.h index 7cd574235b63..4539b6cf8ad6 100644 --- a/modules/talkingtree/talking_tree_enum.h +++ b/modules/talkingtree/talking_tree_enum.h @@ -2,5 +2,6 @@ enum class PacketType{ VERSION = 0, - TEXTMESSAGE = 1 + TEXTMESSAGE = 1, + UDPTUNNEL = 2 }; From d631b8fa75d90f61d863c5d73e184edb587ad1fd Mon Sep 17 00:00:00 2001 From: hungrymonkey Date: Fri, 27 Oct 2017 14:22:38 -0700 Subject: [PATCH 6/9] added serialize recieve text --- modules/talkingtree/talking_tree.cpp | 25 ++++++++++++++++++++++--- modules/talkingtree/talking_tree.h | 2 +- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/modules/talkingtree/talking_tree.cpp b/modules/talkingtree/talking_tree.cpp index e07593481ece..d93749a6ae99 100644 --- a/modules/talkingtree/talking_tree.cpp +++ b/modules/talkingtree/talking_tree.cpp @@ -12,7 +12,7 @@ void TalkingTree::_bind_methods() { ClassDB::bind_method(D_METHOD("is_network_server"), &TalkingTree::is_network_server); ClassDB::bind_method(D_METHOD("has_network_peer"), &TalkingTree::has_network_peer); ClassDB::bind_method(D_METHOD("get_network_connected_peers"), &TalkingTree::get_network_connected_peers); - + ADD_SIGNAL(MethodInfo("text_message", PropertyInfo(Variant::STRING, "message"), PropertyInfo(Variant::INT, "sender_id"))); } TalkingTree::TalkingTree() { @@ -21,16 +21,35 @@ void TalkingTree::send_text(String msg) { TalkingTreeProto::TextMessage txtMsg; CharString m = msg.utf8(); txtMsg.set_message(m.get_data(), m.length()); + } -void TalkingTree::_send_packet(PacketType type, google::protobuf::Message &message){ +void TalkingTree::_send_packet(PacketType type, google::protobuf::Message &message, NetworkedMultiplayerPeer::TransferMode transferMode){ Vector packet; packet.resize(1 + 4 + message.ByteSize()); packet[0] = (uint8_t)type; encode_uint32(message.ByteSize(), &packet[1]); message.SerializeToArray( &packet[5], message.ByteSize()); + network_peer->set_transfer_mode(transferMode); + + } void TalkingTree::_serialize_packet(int p_from, const uint8_t *p_packet, int p_packet_len) { - uint8_t packet_type = p_packet[0]; + PacketType packet_type = (PacketType) p_packet[0]; + switch(packet_type){ + case PacketType::VERSION: { + } break; + case PacketType::UDPTUNNEL: { + } break; + case PacketType::TEXTMESSAGE: { + TalkingTreeProto::TextMessage txtMsg; + txtMsg.ParseFromArray( p_packet, p_packet_len ); + String msg; + msg.parse_utf8(txtMsg.message().c_str(), txtMsg.message().length()); + this->emit_signal("text_message", msg, p_from); + } break; + default: + break; + } } bool TalkingTree::is_network_server() const { diff --git a/modules/talkingtree/talking_tree.h b/modules/talkingtree/talking_tree.h index b01592da8a67..6b5aba9a98ee 100644 --- a/modules/talkingtree/talking_tree.h +++ b/modules/talkingtree/talking_tree.h @@ -25,7 +25,7 @@ class TalkingTree : public Reference { Set connected_peers; int last_send_cache_id; Ref network_peer; - void _send_packet(PacketType type, google::protobuf::Message &message); + void _send_packet(PacketType type, google::protobuf::Message &message, NetworkedMultiplayerPeer::TransferMode transfer); void _serialize_packet(int p_from, const uint8_t *p_packet, int p_packet_len); }; From b3a9cff3920752984f7657391d6d5dd9bd7a7c8a Mon Sep 17 00:00:00 2001 From: hungrymonkey Date: Fri, 27 Oct 2017 14:58:16 -0700 Subject: [PATCH 7/9] added send peer --- modules/talkingtree/talking_tree.cpp | 8 ++++---- modules/talkingtree/talking_tree.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/talkingtree/talking_tree.cpp b/modules/talkingtree/talking_tree.cpp index d93749a6ae99..af2fcf13c259 100644 --- a/modules/talkingtree/talking_tree.cpp +++ b/modules/talkingtree/talking_tree.cpp @@ -21,17 +21,17 @@ void TalkingTree::send_text(String msg) { TalkingTreeProto::TextMessage txtMsg; CharString m = msg.utf8(); txtMsg.set_message(m.get_data(), m.length()); - + _send_packet(0, PacketType::TEXTMESSAGE, txtMsg, NetworkedMultiplayerPeer::TRANSFER_MODE_RELIABLE); } -void TalkingTree::_send_packet(PacketType type, google::protobuf::Message &message, NetworkedMultiplayerPeer::TransferMode transferMode){ +void TalkingTree::_send_packet(int p_to, PacketType type, google::protobuf::Message &message, NetworkedMultiplayerPeer::TransferMode transferMode){ Vector packet; packet.resize(1 + 4 + message.ByteSize()); packet[0] = (uint8_t)type; encode_uint32(message.ByteSize(), &packet[1]); message.SerializeToArray( &packet[5], message.ByteSize()); network_peer->set_transfer_mode(transferMode); - - + network_peer->set_target_peer(0); + network_peer->put_packet(packet.ptr(), packet.size()); } void TalkingTree::_serialize_packet(int p_from, const uint8_t *p_packet, int p_packet_len) { PacketType packet_type = (PacketType) p_packet[0]; diff --git a/modules/talkingtree/talking_tree.h b/modules/talkingtree/talking_tree.h index 6b5aba9a98ee..fc45b6ff01fb 100644 --- a/modules/talkingtree/talking_tree.h +++ b/modules/talkingtree/talking_tree.h @@ -25,7 +25,7 @@ class TalkingTree : public Reference { Set connected_peers; int last_send_cache_id; Ref network_peer; - void _send_packet(PacketType type, google::protobuf::Message &message, NetworkedMultiplayerPeer::TransferMode transfer); + void _send_packet(int p_to, PacketType type, google::protobuf::Message &message, NetworkedMultiplayerPeer::TransferMode transfer); void _serialize_packet(int p_from, const uint8_t *p_packet, int p_packet_len); }; From 297f151d1fc318746caec15b5e4f7b0e3159e853 Mon Sep 17 00:00:00 2001 From: hungrymonkey Date: Fri, 27 Oct 2017 20:18:36 -0700 Subject: [PATCH 8/9] added send text call --- modules/talkingtree/talking_tree.cpp | 37 ++++++++++++++++++++++++++-- modules/talkingtree/talking_tree.h | 3 ++- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/modules/talkingtree/talking_tree.cpp b/modules/talkingtree/talking_tree.cpp index af2fcf13c259..f58205144e10 100644 --- a/modules/talkingtree/talking_tree.cpp +++ b/modules/talkingtree/talking_tree.cpp @@ -12,6 +12,7 @@ void TalkingTree::_bind_methods() { ClassDB::bind_method(D_METHOD("is_network_server"), &TalkingTree::is_network_server); ClassDB::bind_method(D_METHOD("has_network_peer"), &TalkingTree::has_network_peer); ClassDB::bind_method(D_METHOD("get_network_connected_peers"), &TalkingTree::get_network_connected_peers); + ClassDB::bind_method(D_METHOD("send_text", "message"), &TalkingTree::send_text); ADD_SIGNAL(MethodInfo("text_message", PropertyInfo(Variant::STRING, "message"), PropertyInfo(Variant::INT, "sender_id"))); } @@ -25,6 +26,7 @@ void TalkingTree::send_text(String msg) { } void TalkingTree::_send_packet(int p_to, PacketType type, google::protobuf::Message &message, NetworkedMultiplayerPeer::TransferMode transferMode){ Vector packet; + //incorrect packet.resize(1 + 4 + message.ByteSize()); packet[0] = (uint8_t)type; encode_uint32(message.ByteSize(), &packet[1]); @@ -33,8 +35,10 @@ void TalkingTree::_send_packet(int p_to, PacketType type, google::protobuf::Mess network_peer->set_target_peer(0); network_peer->put_packet(packet.ptr(), packet.size()); } -void TalkingTree::_serialize_packet(int p_from, const uint8_t *p_packet, int p_packet_len) { +void TalkingTree::_network_process_packet(int p_from, const uint8_t *p_packet, int p_packet_len) { PacketType packet_type = (PacketType) p_packet[0]; + const uint8_t * proto_packet = &p_packet[5]; + int proto_packet_len = p_packet_len - 5; switch(packet_type){ case PacketType::VERSION: { } break; @@ -42,7 +46,7 @@ void TalkingTree::_serialize_packet(int p_from, const uint8_t *p_packet, int p_p } break; case PacketType::TEXTMESSAGE: { TalkingTreeProto::TextMessage txtMsg; - txtMsg.ParseFromArray( p_packet, p_packet_len ); + txtMsg.ParseFromArray( proto_packet, proto_packet_len ); String msg; msg.parse_utf8(txtMsg.message().c_str(), txtMsg.message().length()); this->emit_signal("text_message", msg, p_from); @@ -92,3 +96,32 @@ Vector TalkingTree::get_network_connected_peers() const { } return ret; } + +void TalkingTree::_network_poll() { + +if (!network_peer.is_valid() || network_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_DISCONNECTED) + return; + + network_peer->poll(); + + if (!network_peer.is_valid()) //it's possible that polling might have resulted in a disconnection, so check here + return; + + while (network_peer->get_available_packet_count()) { + + int sender = network_peer->get_packet_peer(); + const uint8_t *packet; + int len; + + Error err = network_peer->get_packet(&packet, len); + if (err != OK) { + ERR_PRINT("Error getting packet!"); + } + + _network_process_packet(sender, packet, len); + + if (!network_peer.is_valid()) { + break; //it's also possible that a packet or RPC caused a disconnection, so also check here + } + } +} \ No newline at end of file diff --git a/modules/talkingtree/talking_tree.h b/modules/talkingtree/talking_tree.h index fc45b6ff01fb..fda31b32816c 100644 --- a/modules/talkingtree/talking_tree.h +++ b/modules/talkingtree/talking_tree.h @@ -26,7 +26,8 @@ class TalkingTree : public Reference { int last_send_cache_id; Ref network_peer; void _send_packet(int p_to, PacketType type, google::protobuf::Message &message, NetworkedMultiplayerPeer::TransferMode transfer); - void _serialize_packet(int p_from, const uint8_t *p_packet, int p_packet_len); + void _network_process_packet(int p_from, const uint8_t *p_packet, int p_packet_len); + void _network_poll(); }; #endif From 55e7289e8526b148d3bb55917d5ad001a3f77338 Mon Sep 17 00:00:00 2001 From: hungrymonkey Date: Sat, 28 Oct 2017 20:15:15 -0700 Subject: [PATCH 9/9] remove timer from code --- modules/talkingtree/talking_tree.cpp | 18 ++++++++++++++---- modules/talkingtree/talking_tree.h | 3 +++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/modules/talkingtree/talking_tree.cpp b/modules/talkingtree/talking_tree.cpp index f58205144e10..b61e8788f0a7 100644 --- a/modules/talkingtree/talking_tree.cpp +++ b/modules/talkingtree/talking_tree.cpp @@ -13,10 +13,12 @@ void TalkingTree::_bind_methods() { ClassDB::bind_method(D_METHOD("has_network_peer"), &TalkingTree::has_network_peer); ClassDB::bind_method(D_METHOD("get_network_connected_peers"), &TalkingTree::get_network_connected_peers); ClassDB::bind_method(D_METHOD("send_text", "message"), &TalkingTree::send_text); + ClassDB::bind_method(D_METHOD("poll"), &TalkingTree::poll); + ADD_SIGNAL(MethodInfo("text_message", PropertyInfo(Variant::STRING, "message"), PropertyInfo(Variant::INT, "sender_id"))); } -TalkingTree::TalkingTree() { +TalkingTree::TalkingTree(){ } void TalkingTree::send_text(String msg) { TalkingTreeProto::TextMessage txtMsg; @@ -99,8 +101,8 @@ Vector TalkingTree::get_network_connected_peers() const { void TalkingTree::_network_poll() { -if (!network_peer.is_valid() || network_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_DISCONNECTED) - return; + if (!network_peer.is_valid() || network_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_DISCONNECTED) + return; network_peer->poll(); @@ -124,4 +126,12 @@ if (!network_peer.is_valid() || network_peer->get_connection_status() == Network break; //it's also possible that a packet or RPC caused a disconnection, so also check here } } -} \ No newline at end of file +} + +void TalkingTree::poll(){ + while(true){ + //_timer->set_wait_time(500.0/1000.0); + _network_poll(); + //_timer->start(); + } +} diff --git a/modules/talkingtree/talking_tree.h b/modules/talkingtree/talking_tree.h index fda31b32816c..46ace9e1f66a 100644 --- a/modules/talkingtree/talking_tree.h +++ b/modules/talkingtree/talking_tree.h @@ -6,6 +6,7 @@ #include "io/networked_multiplayer_peer.h" #include "ustring.h" #include "talking_tree_enum.h" +#include "scene/main/timer.h" #include class TalkingTree : public Reference { @@ -21,6 +22,7 @@ class TalkingTree : public Reference { bool is_network_server() const; bool has_network_peer() const; void send_text(String msg); + void poll(); private: Set connected_peers; int last_send_cache_id; @@ -28,6 +30,7 @@ class TalkingTree : public Reference { void _send_packet(int p_to, PacketType type, google::protobuf::Message &message, NetworkedMultiplayerPeer::TransferMode transfer); void _network_process_packet(int p_from, const uint8_t *p_packet, int p_packet_len); void _network_poll(); + //Ref _timer; }; #endif