fix(CAPI): 🐛 fix crash when game end
tags/0.1.0^2
| @@ -61,7 +61,7 @@ public: | |||
| virtual bool UseProp(THUAI6::PropType prop) = 0; | |||
| virtual bool ThrowProp(THUAI6::PropType prop) = 0; | |||
| virtual bool UseSkill(int32_t skillID) = 0; | |||
| virtual bool SendMessage(int64_t toID, std::string message) = 0; | |||
| virtual bool SendMessage(int64_t toID, std::string message, bool binary) = 0; | |||
| virtual bool HaveMessage() = 0; | |||
| virtual std::pair<int64_t, std::string> GetMessage() = 0; | |||
| @@ -119,7 +119,8 @@ public: | |||
| virtual std::future<bool> EndAllAction() = 0; | |||
| // 发送信息、接受信息,注意收消息时无消息则返回nullopt | |||
| virtual std::future<bool> SendMessage(int64_t, std::string) = 0; | |||
| virtual std::future<bool> SendTextMessage(int64_t, std::string) = 0; | |||
| virtual std::future<bool> SendBinaryMessage(int64_t, std::string) = 0; | |||
| [[nodiscard]] virtual bool HaveMessage() = 0; | |||
| [[nodiscard]] virtual std::pair<int64_t, std::string> GetMessage() = 0; | |||
| @@ -246,7 +247,8 @@ public: | |||
| std::future<bool> StartOpenChest() override; | |||
| std::future<bool> EndAllAction() override; | |||
| std::future<bool> SendMessage(int64_t, std::string) override; | |||
| std::future<bool> SendTextMessage(int64_t, std::string) override; | |||
| std::future<bool> SendBinaryMessage(int64_t, std::string) override; | |||
| [[nodiscard]] bool HaveMessage() override; | |||
| [[nodiscard]] std::pair<int64_t, std::string> GetMessage() override; | |||
| @@ -336,7 +338,8 @@ public: | |||
| std::future<bool> StartOpenChest() override; | |||
| std::future<bool> EndAllAction() override; | |||
| std::future<bool> SendMessage(int64_t, std::string) override; | |||
| std::future<bool> SendTextMessage(int64_t, std::string) override; | |||
| std::future<bool> SendBinaryMessage(int64_t, std::string) override; | |||
| [[nodiscard]] bool HaveMessage() override; | |||
| [[nodiscard]] std::pair<int64_t, std::string> GetMessage() override; | |||
| @@ -418,7 +421,8 @@ public: | |||
| std::future<bool> StartOpenChest() override; | |||
| std::future<bool> EndAllAction() override; | |||
| std::future<bool> SendMessage(int64_t, std::string) override; | |||
| std::future<bool> SendTextMessage(int64_t, std::string) override; | |||
| std::future<bool> SendBinaryMessage(int64_t, std::string) override; | |||
| [[nodiscard]] bool HaveMessage() override; | |||
| [[nodiscard]] std::pair<int64_t, std::string> GetMessage() override; | |||
| @@ -493,7 +497,8 @@ public: | |||
| std::future<bool> StartOpenChest() override; | |||
| std::future<bool> EndAllAction() override; | |||
| std::future<bool> SendMessage(int64_t, std::string) override; | |||
| std::future<bool> SendTextMessage(int64_t, std::string) override; | |||
| std::future<bool> SendBinaryMessage(int64_t, std::string) override; | |||
| [[nodiscard]] bool HaveMessage() override; | |||
| [[nodiscard]] std::pair<int64_t, std::string> GetMessage() override; | |||
| @@ -32,7 +32,7 @@ public: | |||
| bool UseProp(THUAI6::PropType prop, int64_t playerID); | |||
| bool ThrowProp(THUAI6::PropType prop, int64_t playerID); | |||
| bool UseSkill(int32_t skillID, int64_t playerID); | |||
| bool SendMessage(int64_t toID, std::string message, int64_t playerID); | |||
| bool SendMessage(int64_t toID, std::string message, bool binary, int64_t playerID); | |||
| bool OpenDoor(int64_t playerID); | |||
| bool CloseDoor(int64_t playerID); | |||
| bool SkipWindow(int64_t playerID); | |||
| @@ -118,7 +118,7 @@ private: | |||
| bool ThrowProp(THUAI6::PropType prop) override; | |||
| bool UseSkill(int32_t skillID) override; | |||
| bool SendMessage(int64_t toID, std::string message) override; | |||
| bool SendMessage(int64_t toID, std::string message, bool binary) override; | |||
| bool HaveMessage() override; | |||
| std::pair<int64_t, std::string> GetMessage() override; | |||
| @@ -172,6 +172,13 @@ namespace THUAI6 | |||
| Opened = 2, | |||
| }; | |||
| enum class NewsType : unsigned char | |||
| { | |||
| NullNewsType = 0, | |||
| TextMessage = 1, | |||
| BinaryMessage = 2, | |||
| }; | |||
| // 玩家类 | |||
| struct Player | |||
| { | |||
| @@ -206,6 +206,12 @@ namespace Proto2THUAI6 | |||
| }; | |||
| inline std::map<protobuf::MessageOfNews::NewsCase, THUAI6::NewsType> newsTypeDict{ | |||
| {protobuf::MessageOfNews::NewsCase::NEWS_NOT_SET, THUAI6::NewsType::NullNewsType}, | |||
| {protobuf::MessageOfNews::NewsCase::kTextMessage, THUAI6::NewsType::TextMessage}, | |||
| {protobuf::MessageOfNews::NewsCase::kBinaryMessage, THUAI6::NewsType::BinaryMessage}, | |||
| }; | |||
| // 用于将Protobuf中的类转换为THUAI6的类 | |||
| inline std::shared_ptr<THUAI6::Tricker> Protobuf2THUAI6Tricker(const protobuf::MessageOfTricker& trickerMsg) | |||
| { | |||
| @@ -460,10 +466,13 @@ namespace THUAI62Proto | |||
| return pickMsg; | |||
| } | |||
| inline protobuf::SendMsg THUAI62ProtobufSend(std::string msg, int64_t toID, int64_t id) | |||
| inline protobuf::SendMsg THUAI62ProtobufSend(std::string msg, int64_t toID, bool binary, int64_t id) | |||
| { | |||
| protobuf::SendMsg sendMsg; | |||
| sendMsg.set_message(msg); | |||
| if (binary) | |||
| sendMsg.set_binary_message(msg); | |||
| else | |||
| sendMsg.set_text_message(msg); | |||
| sendMsg.set_to_player_id(toID); | |||
| sendMsg.set_player_id(id); | |||
| return sendMsg; | |||
| @@ -190,16 +190,28 @@ std::future<bool> TrickerAPI::EndAllAction() | |||
| { return logic.EndAllAction(); }); | |||
| } | |||
| std::future<bool> StudentAPI::SendMessage(int64_t toID, std::string message) | |||
| std::future<bool> StudentAPI::SendTextMessage(int64_t toID, std::string message) | |||
| { | |||
| return std::async(std::launch::async, [=]() | |||
| { return logic.SendMessage(toID, message); }); | |||
| { return logic.SendMessage(toID, message, false); }); | |||
| } | |||
| std::future<bool> TrickerAPI::SendMessage(int64_t toID, std::string message) | |||
| std::future<bool> TrickerAPI::SendTextMessage(int64_t toID, std::string message) | |||
| { | |||
| return std::async(std::launch::async, [=]() | |||
| { return logic.SendMessage(toID, message); }); | |||
| { return logic.SendMessage(toID, message, false); }); | |||
| } | |||
| std::future<bool> StudentAPI::SendBinaryMessage(int64_t toID, std::string message) | |||
| { | |||
| return std::async(std::launch::async, [=]() | |||
| { return logic.SendMessage(toID, message, false); }); | |||
| } | |||
| std::future<bool> TrickerAPI::SendBinaryMessage(int64_t toID, std::string message) | |||
| { | |||
| return std::async(std::launch::async, [=]() | |||
| { return logic.SendMessage(toID, message, false); }); | |||
| } | |||
| bool StudentAPI::HaveMessage() | |||
| @@ -78,11 +78,11 @@ bool Communication::UseSkill(int32_t skillID, int64_t playerID) | |||
| return false; | |||
| } | |||
| bool Communication::SendMessage(int64_t toID, std::string message, int64_t playerID) | |||
| bool Communication::SendMessage(int64_t toID, std::string message, bool binary, int64_t playerID) | |||
| { | |||
| protobuf::BoolRes sendMessageResult; | |||
| ClientContext context; | |||
| auto request = THUAI62Proto::THUAI62ProtobufSend(message, toID, playerID); | |||
| auto request = THUAI62Proto::THUAI62ProtobufSend(message, toID, binary, playerID); | |||
| auto status = THUAI6Stub->SendMessage(&context, request, &sendMessageResult); | |||
| if (status.ok()) | |||
| return sendMessageResult.act_success(); | |||
| @@ -352,23 +352,43 @@ std::future<bool> TrickerDebugAPI::EndAllAction() | |||
| return result; }); | |||
| } | |||
| std::future<bool> StudentDebugAPI::SendMessage(int64_t toID, std::string message) | |||
| std::future<bool> StudentDebugAPI::SendTextMessage(int64_t toID, std::string message) | |||
| { | |||
| logger->info("SendMessage: toID = {}, message = {}, called at {}ms", toID, message, Time::TimeSinceStart(startPoint)); | |||
| logger->info("SendTextMessage: toID = {}, message = {}, called at {}ms", toID, message, Time::TimeSinceStart(startPoint)); | |||
| return std::async(std::launch::async, [=]() | |||
| { auto result = logic.SendMessage(toID, message); | |||
| { auto result = logic.SendMessage(toID, message, false); | |||
| if (!result) | |||
| logger->warn("SendMessage: failed at {}ms", Time::TimeSinceStart(startPoint)); | |||
| logger->warn("SendTextMessage: failed at {}ms", Time::TimeSinceStart(startPoint)); | |||
| return result; }); | |||
| } | |||
| std::future<bool> TrickerDebugAPI::SendMessage(int64_t toID, std::string message) | |||
| std::future<bool> TrickerDebugAPI::SendTextMessage(int64_t toID, std::string message) | |||
| { | |||
| logger->info("SendMessage: toID = {}, message = {}, called at {}ms", toID, message, Time::TimeSinceStart(startPoint)); | |||
| logger->info("SendTextMessage: toID = {}, message = {}, called at {}ms", toID, message, Time::TimeSinceStart(startPoint)); | |||
| return std::async(std::launch::async, [=]() | |||
| { auto result = logic.SendMessage(toID, message); | |||
| { auto result = logic.SendMessage(toID, message, false); | |||
| if (!result) | |||
| logger->warn("SendMessage: failed at {}ms", Time::TimeSinceStart(startPoint)); | |||
| logger->warn("SendTextMessage: failed at {}ms", Time::TimeSinceStart(startPoint)); | |||
| return result; }); | |||
| } | |||
| std::future<bool> StudentDebugAPI::SendBinaryMessage(int64_t toID, std::string message) | |||
| { | |||
| logger->info("SendBinaryMessage: toID = {}, message = {}, called at {}ms", toID, message, Time::TimeSinceStart(startPoint)); | |||
| return std::async(std::launch::async, [=]() | |||
| { auto result = logic.SendMessage(toID, message, true); | |||
| if (!result) | |||
| logger->warn("SendBinaryMessage: failed at {}ms", Time::TimeSinceStart(startPoint)); | |||
| return result; }); | |||
| } | |||
| std::future<bool> TrickerDebugAPI::SendBinaryMessage(int64_t toID, std::string message) | |||
| { | |||
| logger->info("SendBinaryMessage: toID = {}, message = {}, called at {}ms", toID, message, Time::TimeSinceStart(startPoint)); | |||
| return std::async(std::launch::async, [=]() | |||
| { auto result = logic.SendMessage(toID, message, true); | |||
| if (!result) | |||
| logger->warn("SendBinaryMessage: failed at {}ms", Time::TimeSinceStart(startPoint)); | |||
| return result; }); | |||
| } | |||
| @@ -214,10 +214,10 @@ bool Logic::UseSkill(int32_t skill) | |||
| return pComm->UseSkill(skill, playerID); | |||
| } | |||
| bool Logic::SendMessage(int64_t toID, std::string message) | |||
| bool Logic::SendMessage(int64_t toID, std::string message, bool binary) | |||
| { | |||
| logger->debug("Called SendMessage"); | |||
| return pComm->SendMessage(toID, message, playerID); | |||
| return pComm->SendMessage(toID, message, binary, playerID); | |||
| } | |||
| bool Logic::HaveMessage() | |||
| @@ -369,7 +369,6 @@ void Logic::ProcessMessage() | |||
| break; | |||
| } | |||
| } | |||
| AILoop = false; | |||
| { | |||
| std::lock_guard<std::mutex> lock(mtxBuffer); | |||
| bufferUpdated = true; | |||
| @@ -377,6 +376,7 @@ void Logic::ProcessMessage() | |||
| } | |||
| cvBuffer.notify_one(); | |||
| logger->info("Game End!"); | |||
| AILoop = false; | |||
| }; | |||
| std::thread(messageThread).detach(); | |||
| } | |||
| @@ -567,7 +567,20 @@ void Logic::LoadBufferCase(const protobuf::MessageOfObj& item) | |||
| { | |||
| auto news = item.news_message(); | |||
| if (news.to_id() == playerID) | |||
| messageQueue.emplace(std::make_pair(news.from_id(), news.news())); | |||
| { | |||
| if (Proto2THUAI6::newsTypeDict[news.news_case()] == THUAI6::NewsType::TextMessage) | |||
| { | |||
| messageQueue.emplace(std::make_pair(news.to_id(), news.text_message())); | |||
| logger->debug("Add News!"); | |||
| } | |||
| else if (Proto2THUAI6::newsTypeDict[news.news_case()] == THUAI6::NewsType::BinaryMessage) | |||
| { | |||
| messageQueue.emplace(std::make_pair(news.to_id(), news.binary_message())); | |||
| logger->debug("Add News!"); | |||
| } | |||
| else | |||
| logger->error("Unknown NewsType!"); | |||
| } | |||
| break; | |||
| } | |||
| case THUAI6::MessageOfObj::NullMessageOfObj: | |||
| @@ -20,7 +20,7 @@ static constexpr std::string_view welcomeString = R"welcome( | |||
| _____ _ _ _ _ _ ___ __ | |||
| |_ _| | | | | | | / \ |_ _/ /_ | |||
| | | | |_| | | | |/ _ \ | | '_ \ | |||
| | | | |_| | | | |/ _ \ | | '_ \ | |||
| | | | _ | |_| / ___ \ | | (_) | | |||
| |_| |_| |_|\___/_/ \_\___\___/ | |||
| @@ -312,7 +312,7 @@ namespace protobuf | |||
| ::_pbi::ConstantInitialized | |||
| ) : | |||
| _impl_{ | |||
| /*decltype(_impl_.news_)*/ {&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}, /*decltype(_impl_.from_id_)*/ int64_t{0}, /*decltype(_impl_.to_id_)*/ int64_t{0}, /*decltype(_impl_._cached_size_)*/ {}} | |||
| /*decltype(_impl_. from_id_)*/ int64_t{0}, /*decltype(_impl_.to_id_)*/ int64_t{0}, /*decltype(_impl_.news_)*/ {}, /*decltype(_impl_._cached_size_)*/ {}, /*decltype(_impl_._oneof_case_)*/ {}} |
|||
| { | |||
| } | |||
| struct MessageOfNewsDefaultTypeInternal | |||
| @@ -612,12 +612,14 @@ const uint32_t TableStruct_Message2Clients_2eproto::offsets[] PROTOBUF_SECTION_V | |||
| ~0u, // no _has_bits_ | |||
| PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfNews, _internal_metadata_), | |||
| ~0u, // no _extensions_ | |||
| ~0u, // no _oneof_case_ | |||
| PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfNews, _impl_._oneof_case_[0]), | |||
| ~0u, // no _weak_field_map_ | |||
| ~0u, // no _inlined_string_donated_ | |||
| PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfNews, _impl_.news_), | |||
| ::_pbi::kInvalidFieldOffsetTag, | |||
| ::_pbi::kInvalidFieldOffsetTag, | |||
| PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfNews, _impl_.from_id_), | |||
| PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfNews, _impl_.to_id_), | |||
| PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfNews, _impl_.news_), | |||
| ~0u, // no _has_bits_ | |||
| PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfObj, _internal_metadata_), | |||
| ~0u, // no _extensions_ | |||
| @@ -690,11 +692,11 @@ static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protode | |||
| {149, -1, -1, sizeof(::protobuf::MessageOfMap_Row)}, | |||
| {156, -1, -1, sizeof(::protobuf::MessageOfMap)}, | |||
| {163, -1, -1, sizeof(::protobuf::MessageOfNews)}, | |||
| {172, -1, -1, sizeof(::protobuf::MessageOfObj)}, | |||
| {191, -1, -1, sizeof(::protobuf::MessageOfAll)}, | |||
| {203, -1, -1, sizeof(::protobuf::MessageToClient)}, | |||
| {212, -1, -1, sizeof(::protobuf::MoveRes)}, | |||
| {221, -1, -1, sizeof(::protobuf::BoolRes)}, | |||
| {174, -1, -1, sizeof(::protobuf::MessageOfObj)}, | |||
| {193, -1, -1, sizeof(::protobuf::MessageOfAll)}, | |||
| {205, -1, -1, sizeof(::protobuf::MessageToClient)}, | |||
| {214, -1, -1, sizeof(::protobuf::MoveRes)}, | |||
| {223, -1, -1, sizeof(::protobuf::BoolRes)}, | |||
| }; | |||
| static const ::_pb::Message* const file_default_instances[] = { | |||
| @@ -775,36 +777,37 @@ const char descriptor_table_protodef_Message2Clients_2eproto[] PROTOBUF_SECTION_ | |||
| "\001(\005\022\t\n\001y\030\002 \001(\005\022\020\n\010progress\030\003 \001(\005\"`\n\014Mess" | |||
| "ageOfMap\022\'\n\003row\030\002 \003(\0132\032.protobuf.Message" | |||
| "OfMap.Row\032\'\n\003Row\022 \n\003col\030\001 \003(\0162\023.protobuf" | |||
| ".PlaceType\"=\n\rMessageOfNews\022\014\n\004news\030\001 \001(" | |||
| "\t\022\017\n\007from_id\030\002 \001(\003\022\r\n\005to_id\030\003 \001(\003\"\244\005\n\014Me" | |||
| "ssageOfObj\0225\n\017student_message\030\001 \001(\0132\032.pr" | |||
| "otobuf.MessageOfStudentH\000\0225\n\017tricker_mes" | |||
| "sage\030\002 \001(\0132\032.protobuf.MessageOfTrickerH\000" | |||
| "\022/\n\014prop_message\030\003 \001(\0132\027.protobuf.Messag" | |||
| "eOfPropH\000\0223\n\016bullet_message\030\004 \001(\0132\031.prot" | |||
| "obuf.MessageOfBulletH\000\022@\n\025bombed_bullet_" | |||
| "message\030\005 \001(\0132\037.protobuf.MessageOfBombed" | |||
| "BulletH\000\0229\n\021classroom_message\030\006 \001(\0132\034.pr" | |||
| "otobuf.MessageOfClassroomH\000\022/\n\014door_mess" | |||
| "age\030\007 \001(\0132\027.protobuf.MessageOfDoorH\000\022/\n\014" | |||
| "gate_message\030\010 \001(\0132\027.protobuf.MessageOfG" | |||
| "ateH\000\0221\n\rchest_message\030\t \001(\0132\030.protobuf." | |||
| "MessageOfChestH\000\022<\n\023hidden_gate_message\030" | |||
| "\n \001(\0132\035.protobuf.MessageOfHiddenGateH\000\022/" | |||
| "\n\014news_message\030\013 \001(\0132\027.protobuf.MessageO" | |||
| "fNewsH\000\022-\n\013map_message\030\014 \001(\0132\026.protobuf." | |||
| "MessageOfMapH\000B\020\n\016message_of_obj\"\234\001\n\014Mes" | |||
| "sageOfAll\022\021\n\tgame_time\030\001 \001(\005\022\030\n\020subject_" | |||
| "finished\030\002 \001(\005\022\031\n\021student_graduated\030\003 \001(" | |||
| "\005\022\026\n\016student_quited\030\004 \001(\005\022\025\n\rstudent_sco" | |||
| "re\030\005 \001(\005\022\025\n\rtricker_score\030\006 \001(\005\"\224\001\n\017Mess" | |||
| "ageToClient\022+\n\013obj_message\030\001 \003(\0132\026.proto" | |||
| "buf.MessageOfObj\022\'\n\ngame_state\030\002 \001(\0162\023.p" | |||
| "rotobuf.GameState\022+\n\013all_message\030\003 \001(\0132\026" | |||
| ".protobuf.MessageOfAll\"J\n\007MoveRes\022\024\n\014act" | |||
| "ual_speed\030\001 \001(\003\022\024\n\014actual_angle\030\002 \001(\001\022\023\n" | |||
| "\013act_success\030\003 \001(\010\"\036\n\007BoolRes\022\023\n\013act_suc" | |||
| "cess\030\001 \001(\010b\006proto3"; | |||
| ".PlaceType\"i\n\rMessageOfNews\022\026\n\014text_mess" | |||
| "age\030\001 \001(\tH\000\022\030\n\016binary_message\030\004 \001(\014H\000\022\017\n" | |||
| "\007from_id\030\002 \001(\003\022\r\n\005to_id\030\003 \001(\003B\006\n\004news\"\244\005" | |||
| "\n\014MessageOfObj\0225\n\017student_message\030\001 \001(\0132" | |||
| "\032.protobuf.MessageOfStudentH\000\0225\n\017tricker" | |||
| "_message\030\002 \001(\0132\032.protobuf.MessageOfTrick" | |||
| "erH\000\022/\n\014prop_message\030\003 \001(\0132\027.protobuf.Me" | |||
| "ssageOfPropH\000\0223\n\016bullet_message\030\004 \001(\0132\031." | |||
| "protobuf.MessageOfBulletH\000\022@\n\025bombed_bul" | |||
| "let_message\030\005 \001(\0132\037.protobuf.MessageOfBo" | |||
| "mbedBulletH\000\0229\n\021classroom_message\030\006 \001(\0132" | |||
| "\034.protobuf.MessageOfClassroomH\000\022/\n\014door_" | |||
| "message\030\007 \001(\0132\027.protobuf.MessageOfDoorH\000" | |||
| "\022/\n\014gate_message\030\010 \001(\0132\027.protobuf.Messag" | |||
| "eOfGateH\000\0221\n\rchest_message\030\t \001(\0132\030.proto" | |||
| "buf.MessageOfChestH\000\022<\n\023hidden_gate_mess" | |||
| "age\030\n \001(\0132\035.protobuf.MessageOfHiddenGate" | |||
| "H\000\022/\n\014news_message\030\013 \001(\0132\027.protobuf.Mess" | |||
| "ageOfNewsH\000\022-\n\013map_message\030\014 \001(\0132\026.proto" | |||
| "buf.MessageOfMapH\000B\020\n\016message_of_obj\"\234\001\n" | |||
| "\014MessageOfAll\022\021\n\tgame_time\030\001 \001(\005\022\030\n\020subj" | |||
| "ect_finished\030\002 \001(\005\022\031\n\021student_graduated\030" | |||
| "\003 \001(\005\022\026\n\016student_quited\030\004 \001(\005\022\025\n\rstudent" | |||
| "_score\030\005 \001(\005\022\025\n\rtricker_score\030\006 \001(\005\"\224\001\n\017" | |||
| "MessageToClient\022+\n\013obj_message\030\001 \003(\0132\026.p" | |||
| "rotobuf.MessageOfObj\022\'\n\ngame_state\030\002 \001(\016" | |||
| "2\023.protobuf.GameState\022+\n\013all_message\030\003 \001" | |||
| "(\0132\026.protobuf.MessageOfAll\"J\n\007MoveRes\022\024\n" | |||
| "\014actual_speed\030\001 \001(\003\022\024\n\014actual_angle\030\002 \001(" | |||
| "\001\022\023\n\013act_success\030\003 \001(\010\"\036\n\007BoolRes\022\023\n\013act" | |||
| "_success\030\001 \001(\010b\006proto3"; | |||
| static const ::_pbi::DescriptorTable* const descriptor_table_Message2Clients_2eproto_deps[1] = { | |||
| &::descriptor_table_MessageType_2eproto, | |||
| }; | |||
| @@ -812,7 +815,7 @@ static ::_pbi::once_flag descriptor_table_Message2Clients_2eproto_once; | |||
| const ::_pbi::DescriptorTable descriptor_table_Message2Clients_2eproto = { | |||
| false, | |||
| false, | |||
| 3378, | |||
| 3422, | |||
| descriptor_table_protodef_Message2Clients_2eproto, | |||
| "Message2Clients.proto", | |||
| &descriptor_table_Message2Clients_2eproto_once, | |||
| @@ -5927,18 +5930,28 @@ namespace protobuf | |||
| MessageOfNews* const _this = this; | |||
| (void)_this; | |||
| new (&_impl_) Impl_{ | |||
| decltype(_impl_.news_){}, decltype(_impl_.from_id_){}, decltype(_impl_.to_id_){}, /*decltype(_impl_._cached_size_)*/ {}}; | |||
| decltype(_impl_.from_id_){}, decltype(_impl_.to_id_){}, decltype(_impl_.news_){}, /*decltype(_impl_._cached_size_)*/ {}, /*decltype(_impl_._oneof_case_)*/ {}}; | |||
| _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); | |||
| _impl_.news_.InitDefault(); | |||
| #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING | |||
| _impl_.news_.Set("", GetArenaForAllocation()); | |||
| #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING | |||
| if (!from._internal_news().empty()) | |||
| ::memcpy(&_impl_.from_id_, &from._impl_.from_id_, static_cast<size_t>(reinterpret_cast<char*>(&_impl_.to_id_) - reinterpret_cast<char*>(&_impl_.from_id_)) + sizeof(_impl_.to_id_)); | |||
| clear_has_news(); | |||
| switch (from.news_case()) | |||
| { | |||
| _this->_impl_.news_.Set(from._internal_news(), _this->GetArenaForAllocation()); | |||
| case kTextMessage: | |||
| { | |||
| _this->_internal_set_text_message(from._internal_text_message()); | |||
| break; | |||
| } | |||
| case kBinaryMessage: | |||
| { | |||
| _this->_internal_set_binary_message(from._internal_binary_message()); | |||
| break; | |||
| } | |||
| case NEWS_NOT_SET: | |||
| { | |||
| break; | |||
| } | |||
| } | |||
| ::memcpy(&_impl_.from_id_, &from._impl_.from_id_, static_cast<size_t>(reinterpret_cast<char*>(&_impl_.to_id_) - reinterpret_cast<char*>(&_impl_.from_id_)) + sizeof(_impl_.to_id_)); | |||
| // @@protoc_insertion_point(copy_constructor:protobuf.MessageOfNews) | |||
| } | |||
| @@ -5949,11 +5962,8 @@ namespace protobuf | |||
| (void)arena; | |||
| (void)is_message_owned; | |||
| new (&_impl_) Impl_{ | |||
| decltype(_impl_.news_){}, decltype(_impl_.from_id_){int64_t{0}}, decltype(_impl_.to_id_){int64_t{0}}, /*decltype(_impl_._cached_size_)*/ {}}; | |||
| _impl_.news_.InitDefault(); | |||
| #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING | |||
| _impl_.news_.Set("", GetArenaForAllocation()); | |||
| #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING | |||
| decltype(_impl_.from_id_){int64_t{0}}, decltype(_impl_.to_id_){int64_t{0}}, decltype(_impl_.news_){}, /*decltype(_impl_._cached_size_)*/ {}, /*decltype(_impl_._oneof_case_)*/ {}}; | |||
| clear_has_news(); | |||
| } | |||
| MessageOfNews::~MessageOfNews() | |||
| @@ -5970,7 +5980,10 @@ namespace protobuf | |||
| inline void MessageOfNews::SharedDtor() | |||
| { | |||
| GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); | |||
| _impl_.news_.Destroy(); | |||
| if (has_news()) | |||
| { | |||
| clear_news(); | |||
| } | |||
| } | |||
| void MessageOfNews::SetCachedSize(int size) const | |||
| @@ -5978,6 +5991,29 @@ namespace protobuf | |||
| _impl_._cached_size_.Set(size); | |||
| } | |||
| void MessageOfNews::clear_news() | |||
| { | |||
| // @@protoc_insertion_point(one_of_clear_start:protobuf.MessageOfNews) | |||
| switch (news_case()) | |||
| { | |||
| case kTextMessage: | |||
| { | |||
| _impl_.news_.text_message_.Destroy(); | |||
| break; | |||
| } | |||
| case kBinaryMessage: | |||
| { | |||
| _impl_.news_.binary_message_.Destroy(); | |||
| break; | |||
| } | |||
| case NEWS_NOT_SET: | |||
| { | |||
| break; | |||
| } | |||
| } | |||
| _impl_._oneof_case_[0] = NEWS_NOT_SET; | |||
| } | |||
| void MessageOfNews::Clear() | |||
| { | |||
| // @@protoc_insertion_point(message_clear_start:protobuf.MessageOfNews) | |||
| @@ -5985,8 +6021,8 @@ namespace protobuf | |||
| // Prevent compiler warnings about cached_has_bits being unused | |||
| (void)cached_has_bits; | |||
| _impl_.news_.ClearToEmpty(); | |||
| ::memset(&_impl_.from_id_, 0, static_cast<size_t>(reinterpret_cast<char*>(&_impl_.to_id_) - reinterpret_cast<char*>(&_impl_.from_id_)) + sizeof(_impl_.to_id_)); | |||
| clear_news(); | |||
| _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); | |||
| } | |||
| @@ -6001,14 +6037,14 @@ namespace protobuf | |||
| ptr = ::_pbi::ReadTag(ptr, &tag); | |||
| switch (tag >> 3) | |||
| { | |||
| // string news = 1; | |||
| // string text_message = 1; | |||
| case 1: | |||
| if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) | |||
| { | |||
| auto str = _internal_mutable_news(); | |||
| auto str = _internal_mutable_text_message(); | |||
| ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); | |||
| CHK_(ptr); | |||
| CHK_(::_pbi::VerifyUTF8(str, "protobuf.MessageOfNews.news")); | |||
| CHK_(::_pbi::VerifyUTF8(str, "protobuf.MessageOfNews.text_message")); | |||
| } | |||
| else | |||
| goto handle_unusual; | |||
| @@ -6033,6 +6069,17 @@ namespace protobuf | |||
| else | |||
| goto handle_unusual; | |||
| continue; | |||
| // bytes binary_message = 4; | |||
| case 4: | |||
| if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) | |||
| { | |||
| auto str = _internal_mutable_binary_message(); | |||
| ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); | |||
| CHK_(ptr); | |||
| } | |||
| else | |||
| goto handle_unusual; | |||
| continue; | |||
| default: | |||
| goto handle_unusual; | |||
| } // switch | |||
| @@ -6067,14 +6114,14 @@ namespace protobuf | |||
| uint32_t cached_has_bits = 0; | |||
| (void)cached_has_bits; | |||
| // string news = 1; | |||
| if (!this->_internal_news().empty()) | |||
| // string text_message = 1; | |||
| if (_internal_has_text_message()) | |||
| { | |||
| ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( | |||
| this->_internal_news().data(), static_cast<int>(this->_internal_news().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "protobuf.MessageOfNews.news" | |||
| this->_internal_text_message().data(), static_cast<int>(this->_internal_text_message().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "protobuf.MessageOfNews.text_message" | |||
| ); | |||
| target = stream->WriteStringMaybeAliased( | |||
| 1, this->_internal_news(), target | |||
| 1, this->_internal_text_message(), target | |||
| ); | |||
| } | |||
| @@ -6092,6 +6139,14 @@ namespace protobuf | |||
| target = ::_pbi::WireFormatLite::WriteInt64ToArray(3, this->_internal_to_id(), target); | |||
| } | |||
| // bytes binary_message = 4; | |||
| if (_internal_has_binary_message()) | |||
| { | |||
| target = stream->WriteBytesMaybeAliased( | |||
| 4, this->_internal_binary_message(), target | |||
| ); | |||
| } | |||
| if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) | |||
| { | |||
| target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( | |||
| @@ -6111,15 +6166,6 @@ namespace protobuf | |||
| // Prevent compiler warnings about cached_has_bits being unused | |||
| (void)cached_has_bits; | |||
| // string news = 1; | |||
| if (!this->_internal_news().empty()) | |||
| { | |||
| total_size += 1 + | |||
| ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( | |||
| this->_internal_news() | |||
| ); | |||
| } | |||
| // int64 from_id = 2; | |||
| if (this->_internal_from_id() != 0) | |||
| { | |||
| @@ -6132,6 +6178,31 @@ namespace protobuf | |||
| total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_to_id()); | |||
| } | |||
| switch (news_case()) | |||
| { | |||
| // string text_message = 1; | |||
| case kTextMessage: | |||
| { | |||
| total_size += 1 + | |||
| ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( | |||
| this->_internal_text_message() | |||
| ); | |||
| break; | |||
| } | |||
| // bytes binary_message = 4; | |||
| case kBinaryMessage: | |||
| { | |||
| total_size += 1 + | |||
| ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( | |||
| this->_internal_binary_message() | |||
| ); | |||
| break; | |||
| } | |||
| case NEWS_NOT_SET: | |||
| { | |||
| break; | |||
| } | |||
| } | |||
| return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); | |||
| } | |||
| @@ -6152,10 +6223,6 @@ namespace protobuf | |||
| uint32_t cached_has_bits = 0; | |||
| (void)cached_has_bits; | |||
| if (!from._internal_news().empty()) | |||
| { | |||
| _this->_internal_set_news(from._internal_news()); | |||
| } | |||
| if (from._internal_from_id() != 0) | |||
| { | |||
| _this->_internal_set_from_id(from._internal_from_id()); | |||
| @@ -6164,6 +6231,23 @@ namespace protobuf | |||
| { | |||
| _this->_internal_set_to_id(from._internal_to_id()); | |||
| } | |||
| switch (from.news_case()) | |||
| { | |||
| case kTextMessage: | |||
| { | |||
| _this->_internal_set_text_message(from._internal_text_message()); | |||
| break; | |||
| } | |||
| case kBinaryMessage: | |||
| { | |||
| _this->_internal_set_binary_message(from._internal_binary_message()); | |||
| break; | |||
| } | |||
| case NEWS_NOT_SET: | |||
| { | |||
| break; | |||
| } | |||
| } | |||
| _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); | |||
| } | |||
| @@ -6184,17 +6268,14 @@ namespace protobuf | |||
| void MessageOfNews::InternalSwap(MessageOfNews* other) | |||
| { | |||
| using std::swap; | |||
| auto* lhs_arena = GetArenaForAllocation(); | |||
| auto* rhs_arena = other->GetArenaForAllocation(); | |||
| _internal_metadata_.InternalSwap(&other->_internal_metadata_); | |||
| ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( | |||
| &_impl_.news_, lhs_arena, &other->_impl_.news_, rhs_arena | |||
| ); | |||
| ::PROTOBUF_NAMESPACE_ID::internal::memswap< | |||
| PROTOBUF_FIELD_OFFSET(MessageOfNews, _impl_.to_id_) + sizeof(MessageOfNews::_impl_.to_id_) - PROTOBUF_FIELD_OFFSET(MessageOfNews, _impl_.from_id_)>( | |||
| reinterpret_cast<char*>(&_impl_.from_id_), | |||
| reinterpret_cast<char*>(&other->_impl_.from_id_) | |||
| ); | |||
| swap(_impl_.news_, other->_impl_.news_); | |||
| swap(_impl_._oneof_case_[0], other->_impl_._oneof_case_[0]); | |||
| } | |||
| ::PROTOBUF_NAMESPACE_ID::Metadata MessageOfNews::GetMetadata() const | |||
| @@ -3677,6 +3677,13 @@ namespace protobuf | |||
| { | |||
| return *internal_default_instance(); | |||
| } | |||
| enum NewsCase | |||
| { | |||
| kTextMessage = 1, | |||
| kBinaryMessage = 4, | |||
| NEWS_NOT_SET = 0, | |||
| }; | |||
| static inline const MessageOfNews* internal_default_instance() | |||
| { | |||
| return reinterpret_cast<const MessageOfNews*>( | |||
| @@ -3776,25 +3783,11 @@ namespace protobuf | |||
| enum : int | |||
| { | |||
| kNewsFieldNumber = 1, | |||
| kFromIdFieldNumber = 2, | |||
| kToIdFieldNumber = 3, | |||
| kTextMessageFieldNumber = 1, | |||
| kBinaryMessageFieldNumber = 4, | |||
| }; | |||
| // string news = 1; | |||
| void clear_news(); | |||
| const std::string& news() const; | |||
| template<typename ArgT0 = const std::string&, typename... ArgT> | |||
| void set_news(ArgT0&& arg0, ArgT... args); | |||
| std::string* mutable_news(); | |||
| PROTOBUF_NODISCARD std::string* release_news(); | |||
| void set_allocated_news(std::string* news); | |||
| private: | |||
| const std::string& _internal_news() const; | |||
| inline PROTOBUF_ALWAYS_INLINE void _internal_set_news(const std::string& value); | |||
| std::string* _internal_mutable_news(); | |||
| public: | |||
| // int64 from_id = 2; | |||
| void clear_from_id(); | |||
| int64_t from_id() const; | |||
| @@ -3815,10 +3808,59 @@ namespace protobuf | |||
| void _internal_set_to_id(int64_t value); | |||
| public: | |||
| // string text_message = 1; | |||
| bool has_text_message() const; | |||
| private: | |||
| bool _internal_has_text_message() const; | |||
| public: | |||
| void clear_text_message(); | |||
| const std::string& text_message() const; | |||
| template<typename ArgT0 = const std::string&, typename... ArgT> | |||
| void set_text_message(ArgT0&& arg0, ArgT... args); | |||
| std::string* mutable_text_message(); | |||
| PROTOBUF_NODISCARD std::string* release_text_message(); | |||
| void set_allocated_text_message(std::string* text_message); | |||
| private: | |||
| const std::string& _internal_text_message() const; | |||
| inline PROTOBUF_ALWAYS_INLINE void _internal_set_text_message(const std::string& value); | |||
| std::string* _internal_mutable_text_message(); | |||
| public: | |||
| // bytes binary_message = 4; | |||
| bool has_binary_message() const; | |||
| private: | |||
| bool _internal_has_binary_message() const; | |||
| public: | |||
| void clear_binary_message(); | |||
| const std::string& binary_message() const; | |||
| template<typename ArgT0 = const std::string&, typename... ArgT> | |||
| void set_binary_message(ArgT0&& arg0, ArgT... args); | |||
| std::string* mutable_binary_message(); | |||
| PROTOBUF_NODISCARD std::string* release_binary_message(); | |||
| void set_allocated_binary_message(std::string* binary_message); | |||
| private: | |||
| const std::string& _internal_binary_message() const; | |||
| inline PROTOBUF_ALWAYS_INLINE void _internal_set_binary_message(const std::string& value); | |||
| std::string* _internal_mutable_binary_message(); | |||
| public: | |||
| void clear_news(); | |||
| NewsCase news_case() const; | |||
| // @@protoc_insertion_point(class_scope:protobuf.MessageOfNews) | |||
| private: | |||
| class _Internal; | |||
| void set_has_text_message(); | |||
| void set_has_binary_message(); | |||
| inline bool has_news() const; | |||
| inline void clear_has_news(); | |||
| template<typename T> | |||
| friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; | |||
| @@ -3826,10 +3868,20 @@ namespace protobuf | |||
| typedef void DestructorSkippable_; | |||
| struct Impl_ | |||
| { | |||
| ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr news_; | |||
| int64_t from_id_; | |||
| int64_t to_id_; | |||
| union NewsUnion | |||
| { | |||
| constexpr NewsUnion() : | |||
| _constinit_{} | |||
| { | |||
| } | |||
| ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized _constinit_; | |||
| ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr text_message_; | |||
| ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr binary_message_; | |||
| } news_; | |||
| mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; | |||
| uint32_t _oneof_case_[1]; | |||
| }; | |||
| union | |||
| { | |||
| @@ -7609,61 +7661,202 @@ namespace protobuf | |||
| // MessageOfNews | |||
| // string news = 1; | |||
| inline void MessageOfNews::clear_news() | |||
| // string text_message = 1; | |||
| inline bool MessageOfNews::_internal_has_text_message() const | |||
| { | |||
| return news_case() == kTextMessage; | |||
| } | |||
| inline bool MessageOfNews::has_text_message() const | |||
| { | |||
| _impl_.news_.ClearToEmpty(); | |||
| return _internal_has_text_message(); | |||
| } | |||
| inline const std::string& MessageOfNews::news() const | |||
| inline void MessageOfNews::set_has_text_message() | |||
| { | |||
| // @@protoc_insertion_point(field_get:protobuf.MessageOfNews.news) | |||
| return _internal_news(); | |||
| _impl_._oneof_case_[0] = kTextMessage; | |||
| } | |||
| inline void MessageOfNews::clear_text_message() | |||
| { | |||
| if (_internal_has_text_message()) | |||
| { | |||
| _impl_.news_.text_message_.Destroy(); | |||
| clear_has_news(); | |||
| } | |||
| } | |||
| inline const std::string& MessageOfNews::text_message() const | |||
| { | |||
| // @@protoc_insertion_point(field_get:protobuf.MessageOfNews.text_message) | |||
| return _internal_text_message(); | |||
| } | |||
| template<typename ArgT0, typename... ArgT> | |||
| inline PROTOBUF_ALWAYS_INLINE void MessageOfNews::set_news(ArgT0&& arg0, ArgT... args) | |||
| inline void MessageOfNews::set_text_message(ArgT0&& arg0, ArgT... args) | |||
| { | |||
| _impl_.news_.Set(static_cast<ArgT0&&>(arg0), args..., GetArenaForAllocation()); | |||
| // @@protoc_insertion_point(field_set:protobuf.MessageOfNews.news) | |||
| if (!_internal_has_text_message()) | |||
| { | |||
| clear_news(); | |||
| set_has_text_message(); | |||
| _impl_.news_.text_message_.InitDefault(); | |||
| } | |||
| _impl_.news_.text_message_.Set(static_cast<ArgT0&&>(arg0), args..., GetArenaForAllocation()); | |||
| // @@protoc_insertion_point(field_set:protobuf.MessageOfNews.text_message) | |||
| } | |||
| inline std::string* MessageOfNews::mutable_news() | |||
| inline std::string* MessageOfNews::mutable_text_message() | |||
| { | |||
| std::string* _s = _internal_mutable_news(); | |||
| // @@protoc_insertion_point(field_mutable:protobuf.MessageOfNews.news) | |||
| std::string* _s = _internal_mutable_text_message(); | |||
| // @@protoc_insertion_point(field_mutable:protobuf.MessageOfNews.text_message) | |||
| return _s; | |||
| } | |||
| inline const std::string& MessageOfNews::_internal_news() const | |||
| inline const std::string& MessageOfNews::_internal_text_message() const | |||
| { | |||
| return _impl_.news_.Get(); | |||
| if (_internal_has_text_message()) | |||
| { | |||
| return _impl_.news_.text_message_.Get(); | |||
| } | |||
| return ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(); | |||
| } | |||
| inline void MessageOfNews::_internal_set_news(const std::string& value) | |||
| inline void MessageOfNews::_internal_set_text_message(const std::string& value) | |||
| { | |||
| _impl_.news_.Set(value, GetArenaForAllocation()); | |||
| if (!_internal_has_text_message()) | |||
| { | |||
| clear_news(); | |||
| set_has_text_message(); | |||
| _impl_.news_.text_message_.InitDefault(); | |||
| } | |||
| _impl_.news_.text_message_.Set(value, GetArenaForAllocation()); | |||
| } | |||
| inline std::string* MessageOfNews::_internal_mutable_news() | |||
| inline std::string* MessageOfNews::_internal_mutable_text_message() | |||
| { | |||
| return _impl_.news_.Mutable(GetArenaForAllocation()); | |||
| if (!_internal_has_text_message()) | |||
| { | |||
| clear_news(); | |||
| set_has_text_message(); | |||
| _impl_.news_.text_message_.InitDefault(); | |||
| } | |||
| return _impl_.news_.text_message_.Mutable(GetArenaForAllocation()); | |||
| } | |||
| inline std::string* MessageOfNews::release_news() | |||
| inline std::string* MessageOfNews::release_text_message() | |||
| { | |||
| // @@protoc_insertion_point(field_release:protobuf.MessageOfNews.news) | |||
| return _impl_.news_.Release(); | |||
| // @@protoc_insertion_point(field_release:protobuf.MessageOfNews.text_message) | |||
| if (_internal_has_text_message()) | |||
| { | |||
| clear_has_news(); | |||
| return _impl_.news_.text_message_.Release(); | |||
| } | |||
| else | |||
| { | |||
| return nullptr; | |||
| } | |||
| } | |||
| inline void MessageOfNews::set_allocated_news(std::string* news) | |||
| inline void MessageOfNews::set_allocated_text_message(std::string* text_message) | |||
| { | |||
| if (news != nullptr) | |||
| if (has_news()) | |||
| { | |||
| clear_news(); | |||
| } | |||
| if (text_message != nullptr) | |||
| { | |||
| set_has_text_message(); | |||
| _impl_.news_.text_message_.InitAllocated(text_message, GetArenaForAllocation()); | |||
| } | |||
| // @@protoc_insertion_point(field_set_allocated:protobuf.MessageOfNews.text_message) | |||
| } | |||
| // bytes binary_message = 4; | |||
| inline bool MessageOfNews::_internal_has_binary_message() const | |||
| { | |||
| return news_case() == kBinaryMessage; | |||
| } | |||
| inline bool MessageOfNews::has_binary_message() const | |||
| { | |||
| return _internal_has_binary_message(); | |||
| } | |||
| inline void MessageOfNews::set_has_binary_message() | |||
| { | |||
| _impl_._oneof_case_[0] = kBinaryMessage; | |||
| } | |||
| inline void MessageOfNews::clear_binary_message() | |||
| { | |||
| if (_internal_has_binary_message()) | |||
| { | |||
| _impl_.news_.binary_message_.Destroy(); | |||
| clear_has_news(); | |||
| } | |||
| } | |||
| inline const std::string& MessageOfNews::binary_message() const | |||
| { | |||
| // @@protoc_insertion_point(field_get:protobuf.MessageOfNews.binary_message) | |||
| return _internal_binary_message(); | |||
| } | |||
| template<typename ArgT0, typename... ArgT> | |||
| inline void MessageOfNews::set_binary_message(ArgT0&& arg0, ArgT... args) | |||
| { | |||
| if (!_internal_has_binary_message()) | |||
| { | |||
| clear_news(); | |||
| set_has_binary_message(); | |||
| _impl_.news_.binary_message_.InitDefault(); | |||
| } | |||
| _impl_.news_.binary_message_.SetBytes(static_cast<ArgT0&&>(arg0), args..., GetArenaForAllocation()); | |||
| // @@protoc_insertion_point(field_set:protobuf.MessageOfNews.binary_message) | |||
| } | |||
| inline std::string* MessageOfNews::mutable_binary_message() | |||
| { | |||
| std::string* _s = _internal_mutable_binary_message(); | |||
| // @@protoc_insertion_point(field_mutable:protobuf.MessageOfNews.binary_message) | |||
| return _s; | |||
| } | |||
| inline const std::string& MessageOfNews::_internal_binary_message() const | |||
| { | |||
| if (_internal_has_binary_message()) | |||
| { | |||
| return _impl_.news_.binary_message_.Get(); | |||
| } | |||
| return ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(); | |||
| } | |||
| inline void MessageOfNews::_internal_set_binary_message(const std::string& value) | |||
| { | |||
| if (!_internal_has_binary_message()) | |||
| { | |||
| clear_news(); | |||
| set_has_binary_message(); | |||
| _impl_.news_.binary_message_.InitDefault(); | |||
| } | |||
| _impl_.news_.binary_message_.Set(value, GetArenaForAllocation()); | |||
| } | |||
| inline std::string* MessageOfNews::_internal_mutable_binary_message() | |||
| { | |||
| if (!_internal_has_binary_message()) | |||
| { | |||
| clear_news(); | |||
| set_has_binary_message(); | |||
| _impl_.news_.binary_message_.InitDefault(); | |||
| } | |||
| return _impl_.news_.binary_message_.Mutable(GetArenaForAllocation()); | |||
| } | |||
| inline std::string* MessageOfNews::release_binary_message() | |||
| { | |||
| // @@protoc_insertion_point(field_release:protobuf.MessageOfNews.binary_message) | |||
| if (_internal_has_binary_message()) | |||
| { | |||
| clear_has_news(); | |||
| return _impl_.news_.binary_message_.Release(); | |||
| } | |||
| else | |||
| { | |||
| return nullptr; | |||
| } | |||
| } | |||
| inline void MessageOfNews::set_allocated_binary_message(std::string* binary_message) | |||
| { | |||
| if (has_news()) | |||
| { | |||
| clear_news(); | |||
| } | |||
| _impl_.news_.SetAllocated(news, GetArenaForAllocation()); | |||
| #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING | |||
| if (_impl_.news_.IsDefault()) | |||
| if (binary_message != nullptr) | |||
| { | |||
| _impl_.news_.Set("", GetArenaForAllocation()); | |||
| set_has_binary_message(); | |||
| _impl_.news_.binary_message_.InitAllocated(binary_message, GetArenaForAllocation()); | |||
| } | |||
| #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING | |||
| // @@protoc_insertion_point(field_set_allocated:protobuf.MessageOfNews.news) | |||
| // @@protoc_insertion_point(field_set_allocated:protobuf.MessageOfNews.binary_message) | |||
| } | |||
| // int64 from_id = 2; | |||
| @@ -7714,6 +7907,18 @@ namespace protobuf | |||
| // @@protoc_insertion_point(field_set:protobuf.MessageOfNews.to_id) | |||
| } | |||
| inline bool MessageOfNews::has_news() const | |||
| { | |||
| return news_case() != NEWS_NOT_SET; | |||
| } | |||
| inline void MessageOfNews::clear_has_news() | |||
| { | |||
| _impl_._oneof_case_[0] = NEWS_NOT_SET; | |||
| } | |||
| inline MessageOfNews::NewsCase MessageOfNews::news_case() const | |||
| { | |||
| return MessageOfNews::NewsCase(_impl_._oneof_case_[0]); | |||
| } | |||
| // ------------------------------------------------------------------- | |||
| // MessageOfObj | |||
| @@ -92,7 +92,7 @@ namespace protobuf | |||
| ::_pbi::ConstantInitialized | |||
| ) : | |||
| _impl_{ | |||
| /*decltype(_impl_.message_)*/ {&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}, /*decltype(_impl_.player_id_)*/ int64_t{0}, /*decltype(_impl_.to_player_id_)*/ int64_t{0}, /*decltype(_impl_._cached_size_)*/ {}} | |||
| /*decltype(_impl_. player_id_)*/ int64_t{0}, /*decltype(_impl_.to_player_id_)*/ int64_t{0}, /*decltype(_impl_.message_)*/ {}, /*decltype(_impl_._cached_size_)*/ {}, /*decltype(_impl_._oneof_case_)*/ {}} |
|||
| { | |||
| } | |||
| struct SendMsgDefaultTypeInternal | |||
| @@ -235,11 +235,13 @@ const uint32_t TableStruct_Message2Server_2eproto::offsets[] PROTOBUF_SECTION_VA | |||
| ~0u, // no _has_bits_ | |||
| PROTOBUF_FIELD_OFFSET(::protobuf::SendMsg, _internal_metadata_), | |||
| ~0u, // no _extensions_ | |||
| ~0u, // no _oneof_case_ | |||
| PROTOBUF_FIELD_OFFSET(::protobuf::SendMsg, _impl_._oneof_case_[0]), | |||
| ~0u, // no _weak_field_map_ | |||
| ~0u, // no _inlined_string_donated_ | |||
| PROTOBUF_FIELD_OFFSET(::protobuf::SendMsg, _impl_.player_id_), | |||
| PROTOBUF_FIELD_OFFSET(::protobuf::SendMsg, _impl_.to_player_id_), | |||
| ::_pbi::kInvalidFieldOffsetTag, | |||
| ::_pbi::kInvalidFieldOffsetTag, | |||
| PROTOBUF_FIELD_OFFSET(::protobuf::SendMsg, _impl_.message_), | |||
| ~0u, // no _has_bits_ | |||
| PROTOBUF_FIELD_OFFSET(::protobuf::AttackMsg, _internal_metadata_), | |||
| @@ -278,10 +280,10 @@ static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protode | |||
| {11, -1, -1, sizeof(::protobuf::MoveMsg)}, | |||
| {20, -1, -1, sizeof(::protobuf::PropMsg)}, | |||
| {28, -1, -1, sizeof(::protobuf::SendMsg)}, | |||
| {37, -1, -1, sizeof(::protobuf::AttackMsg)}, | |||
| {45, -1, -1, sizeof(::protobuf::IDMsg)}, | |||
| {52, -1, -1, sizeof(::protobuf::TreatAndRescueMsg)}, | |||
| {60, -1, -1, sizeof(::protobuf::SkillMsg)}, | |||
| {39, -1, -1, sizeof(::protobuf::AttackMsg)}, | |||
| {47, -1, -1, sizeof(::protobuf::IDMsg)}, | |||
| {54, -1, -1, sizeof(::protobuf::TreatAndRescueMsg)}, | |||
| {62, -1, -1, sizeof(::protobuf::SkillMsg)}, | |||
| }; | |||
| static const ::_pb::Message* const file_default_instances[] = { | |||
| @@ -305,13 +307,15 @@ const char descriptor_table_protodef_Message2Server_2eproto[] PROTOBUF_SECTION_V | |||
| "eMsg\022\021\n\tplayer_id\030\001 \001(\003\022\r\n\005angle\030\002 \001(\001\022\034" | |||
| "\n\024time_in_milliseconds\030\003 \001(\003\"C\n\007PropMsg\022" | |||
| "\021\n\tplayer_id\030\001 \001(\003\022%\n\tprop_type\030\002 \001(\0162\022." | |||
| "protobuf.PropType\"C\n\007SendMsg\022\021\n\tplayer_i" | |||
| "d\030\001 \001(\003\022\024\n\014to_player_id\030\002 \001(\003\022\017\n\007message" | |||
| "\030\003 \001(\t\"-\n\tAttackMsg\022\021\n\tplayer_id\030\001 \001(\003\022\r" | |||
| "\n\005angle\030\002 \001(\001\"\032\n\005IDMsg\022\021\n\tplayer_id\030\001 \001(" | |||
| "\003\"<\n\021TreatAndRescueMsg\022\021\n\tplayer_id\030\001 \001(" | |||
| "\003\022\024\n\014to_player_id\030\002 \001(\003\"/\n\010SkillMsg\022\021\n\tp" | |||
| "layer_id\030\001 \001(\003\022\020\n\010skill_id\030\002 \001(\005b\006proto3"; | |||
| "protobuf.PropType\"o\n\007SendMsg\022\021\n\tplayer_i" | |||
| "d\030\001 \001(\003\022\024\n\014to_player_id\030\002 \001(\003\022\026\n\014text_me" | |||
| "ssage\030\003 \001(\tH\000\022\030\n\016binary_message\030\004 \001(\014H\000B" | |||
| "\t\n\007message\"-\n\tAttackMsg\022\021\n\tplayer_id\030\001 \001" | |||
| "(\003\022\r\n\005angle\030\002 \001(\001\"\032\n\005IDMsg\022\021\n\tplayer_id\030" | |||
| "\001 \001(\003\"<\n\021TreatAndRescueMsg\022\021\n\tplayer_id\030" | |||
| "\001 \001(\003\022\024\n\014to_player_id\030\002 \001(\003\"/\n\010SkillMsg\022" | |||
| "\021\n\tplayer_id\030\001 \001(\003\022\020\n\010skill_id\030\002 \001(\005b\006pr" | |||
| "oto3"; | |||
| static const ::_pbi::DescriptorTable* const descriptor_table_Message2Server_2eproto_deps[1] = { | |||
| &::descriptor_table_MessageType_2eproto, | |||
| }; | |||
| @@ -319,7 +323,7 @@ static ::_pbi::once_flag descriptor_table_Message2Server_2eproto_once; | |||
| const ::_pbi::DescriptorTable descriptor_table_Message2Server_2eproto = { | |||
| false, | |||
| false, | |||
| 640, | |||
| 684, | |||
| descriptor_table_protodef_Message2Server_2eproto, | |||
| "Message2Server.proto", | |||
| &descriptor_table_Message2Server_2eproto_once, | |||
| @@ -1259,18 +1263,28 @@ namespace protobuf | |||
| SendMsg* const _this = this; | |||
| (void)_this; | |||
| new (&_impl_) Impl_{ | |||
| decltype(_impl_.message_){}, decltype(_impl_.player_id_){}, decltype(_impl_.to_player_id_){}, /*decltype(_impl_._cached_size_)*/ {}}; | |||
| decltype(_impl_.player_id_){}, decltype(_impl_.to_player_id_){}, decltype(_impl_.message_){}, /*decltype(_impl_._cached_size_)*/ {}, /*decltype(_impl_._oneof_case_)*/ {}}; | |||
| _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); | |||
| _impl_.message_.InitDefault(); | |||
| #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING | |||
| _impl_.message_.Set("", GetArenaForAllocation()); | |||
| #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING | |||
| if (!from._internal_message().empty()) | |||
| ::memcpy(&_impl_.player_id_, &from._impl_.player_id_, static_cast<size_t>(reinterpret_cast<char*>(&_impl_.to_player_id_) - reinterpret_cast<char*>(&_impl_.player_id_)) + sizeof(_impl_.to_player_id_)); | |||
| clear_has_message(); | |||
| switch (from.message_case()) | |||
| { | |||
| _this->_impl_.message_.Set(from._internal_message(), _this->GetArenaForAllocation()); | |||
| case kTextMessage: | |||
| { | |||
| _this->_internal_set_text_message(from._internal_text_message()); | |||
| break; | |||
| } | |||
| case kBinaryMessage: | |||
| { | |||
| _this->_internal_set_binary_message(from._internal_binary_message()); | |||
| break; | |||
| } | |||
| case MESSAGE_NOT_SET: | |||
| { | |||
| break; | |||
| } | |||
| } | |||
| ::memcpy(&_impl_.player_id_, &from._impl_.player_id_, static_cast<size_t>(reinterpret_cast<char*>(&_impl_.to_player_id_) - reinterpret_cast<char*>(&_impl_.player_id_)) + sizeof(_impl_.to_player_id_)); | |||
| // @@protoc_insertion_point(copy_constructor:protobuf.SendMsg) | |||
| } | |||
| @@ -1281,11 +1295,8 @@ namespace protobuf | |||
| (void)arena; | |||
| (void)is_message_owned; | |||
| new (&_impl_) Impl_{ | |||
| decltype(_impl_.message_){}, decltype(_impl_.player_id_){int64_t{0}}, decltype(_impl_.to_player_id_){int64_t{0}}, /*decltype(_impl_._cached_size_)*/ {}}; | |||
| _impl_.message_.InitDefault(); | |||
| #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING | |||
| _impl_.message_.Set("", GetArenaForAllocation()); | |||
| #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING | |||
| decltype(_impl_.player_id_){int64_t{0}}, decltype(_impl_.to_player_id_){int64_t{0}}, decltype(_impl_.message_){}, /*decltype(_impl_._cached_size_)*/ {}, /*decltype(_impl_._oneof_case_)*/ {}}; | |||
| clear_has_message(); | |||
| } | |||
| SendMsg::~SendMsg() | |||
| @@ -1302,7 +1313,10 @@ namespace protobuf | |||
| inline void SendMsg::SharedDtor() | |||
| { | |||
| GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); | |||
| _impl_.message_.Destroy(); | |||
| if (has_message()) | |||
| { | |||
| clear_message(); | |||
| } | |||
| } | |||
| void SendMsg::SetCachedSize(int size) const | |||
| @@ -1310,6 +1324,29 @@ namespace protobuf | |||
| _impl_._cached_size_.Set(size); | |||
| } | |||
| void SendMsg::clear_message() | |||
| { | |||
| // @@protoc_insertion_point(one_of_clear_start:protobuf.SendMsg) | |||
| switch (message_case()) | |||
| { | |||
| case kTextMessage: | |||
| { | |||
| _impl_.message_.text_message_.Destroy(); | |||
| break; | |||
| } | |||
| case kBinaryMessage: | |||
| { | |||
| _impl_.message_.binary_message_.Destroy(); | |||
| break; | |||
| } | |||
| case MESSAGE_NOT_SET: | |||
| { | |||
| break; | |||
| } | |||
| } | |||
| _impl_._oneof_case_[0] = MESSAGE_NOT_SET; | |||
| } | |||
| void SendMsg::Clear() | |||
| { | |||
| // @@protoc_insertion_point(message_clear_start:protobuf.SendMsg) | |||
| @@ -1317,8 +1354,8 @@ namespace protobuf | |||
| // Prevent compiler warnings about cached_has_bits being unused | |||
| (void)cached_has_bits; | |||
| _impl_.message_.ClearToEmpty(); | |||
| ::memset(&_impl_.player_id_, 0, static_cast<size_t>(reinterpret_cast<char*>(&_impl_.to_player_id_) - reinterpret_cast<char*>(&_impl_.player_id_)) + sizeof(_impl_.to_player_id_)); | |||
| clear_message(); | |||
| _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); | |||
| } | |||
| @@ -1353,14 +1390,25 @@ namespace protobuf | |||
| else | |||
| goto handle_unusual; | |||
| continue; | |||
| // string message = 3; | |||
| // string text_message = 3; | |||
| case 3: | |||
| if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) | |||
| { | |||
| auto str = _internal_mutable_message(); | |||
| auto str = _internal_mutable_text_message(); | |||
| ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); | |||
| CHK_(ptr); | |||
| CHK_(::_pbi::VerifyUTF8(str, "protobuf.SendMsg.text_message")); | |||
| } | |||
| else | |||
| goto handle_unusual; | |||
| continue; | |||
| // bytes binary_message = 4; | |||
| case 4: | |||
| if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) | |||
| { | |||
| auto str = _internal_mutable_binary_message(); | |||
| ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); | |||
| CHK_(ptr); | |||
| CHK_(::_pbi::VerifyUTF8(str, "protobuf.SendMsg.message")); | |||
| } | |||
| else | |||
| goto handle_unusual; | |||
| @@ -1413,14 +1461,22 @@ namespace protobuf | |||
| target = ::_pbi::WireFormatLite::WriteInt64ToArray(2, this->_internal_to_player_id(), target); | |||
| } | |||
| // string message = 3; | |||
| if (!this->_internal_message().empty()) | |||
| // string text_message = 3; | |||
| if (_internal_has_text_message()) | |||
| { | |||
| ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( | |||
| this->_internal_message().data(), static_cast<int>(this->_internal_message().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "protobuf.SendMsg.message" | |||
| this->_internal_text_message().data(), static_cast<int>(this->_internal_text_message().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "protobuf.SendMsg.text_message" | |||
| ); | |||
| target = stream->WriteStringMaybeAliased( | |||
| 3, this->_internal_message(), target | |||
| 3, this->_internal_text_message(), target | |||
| ); | |||
| } | |||
| // bytes binary_message = 4; | |||
| if (_internal_has_binary_message()) | |||
| { | |||
| target = stream->WriteBytesMaybeAliased( | |||
| 4, this->_internal_binary_message(), target | |||
| ); | |||
| } | |||
| @@ -1443,15 +1499,6 @@ namespace protobuf | |||
| // Prevent compiler warnings about cached_has_bits being unused | |||
| (void)cached_has_bits; | |||
| // string message = 3; | |||
| if (!this->_internal_message().empty()) | |||
| { | |||
| total_size += 1 + | |||
| ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( | |||
| this->_internal_message() | |||
| ); | |||
| } | |||
| // int64 player_id = 1; | |||
| if (this->_internal_player_id() != 0) | |||
| { | |||
| @@ -1464,6 +1511,31 @@ namespace protobuf | |||
| total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_to_player_id()); | |||
| } | |||
| switch (message_case()) | |||
| { | |||
| // string text_message = 3; | |||
| case kTextMessage: | |||
| { | |||
| total_size += 1 + | |||
| ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( | |||
| this->_internal_text_message() | |||
| ); | |||
| break; | |||
| } | |||
| // bytes binary_message = 4; | |||
| case kBinaryMessage: | |||
| { | |||
| total_size += 1 + | |||
| ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( | |||
| this->_internal_binary_message() | |||
| ); | |||
| break; | |||
| } | |||
| case MESSAGE_NOT_SET: | |||
| { | |||
| break; | |||
| } | |||
| } | |||
| return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); | |||
| } | |||
| @@ -1484,10 +1556,6 @@ namespace protobuf | |||
| uint32_t cached_has_bits = 0; | |||
| (void)cached_has_bits; | |||
| if (!from._internal_message().empty()) | |||
| { | |||
| _this->_internal_set_message(from._internal_message()); | |||
| } | |||
| if (from._internal_player_id() != 0) | |||
| { | |||
| _this->_internal_set_player_id(from._internal_player_id()); | |||
| @@ -1496,6 +1564,23 @@ namespace protobuf | |||
| { | |||
| _this->_internal_set_to_player_id(from._internal_to_player_id()); | |||
| } | |||
| switch (from.message_case()) | |||
| { | |||
| case kTextMessage: | |||
| { | |||
| _this->_internal_set_text_message(from._internal_text_message()); | |||
| break; | |||
| } | |||
| case kBinaryMessage: | |||
| { | |||
| _this->_internal_set_binary_message(from._internal_binary_message()); | |||
| break; | |||
| } | |||
| case MESSAGE_NOT_SET: | |||
| { | |||
| break; | |||
| } | |||
| } | |||
| _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); | |||
| } | |||
| @@ -1516,17 +1601,14 @@ namespace protobuf | |||
| void SendMsg::InternalSwap(SendMsg* other) | |||
| { | |||
| using std::swap; | |||
| auto* lhs_arena = GetArenaForAllocation(); | |||
| auto* rhs_arena = other->GetArenaForAllocation(); | |||
| _internal_metadata_.InternalSwap(&other->_internal_metadata_); | |||
| ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( | |||
| &_impl_.message_, lhs_arena, &other->_impl_.message_, rhs_arena | |||
| ); | |||
| ::PROTOBUF_NAMESPACE_ID::internal::memswap< | |||
| PROTOBUF_FIELD_OFFSET(SendMsg, _impl_.to_player_id_) + sizeof(SendMsg::_impl_.to_player_id_) - PROTOBUF_FIELD_OFFSET(SendMsg, _impl_.player_id_)>( | |||
| reinterpret_cast<char*>(&_impl_.player_id_), | |||
| reinterpret_cast<char*>(&other->_impl_.player_id_) | |||
| ); | |||
| swap(_impl_.message_, other->_impl_.message_); | |||
| swap(_impl_._oneof_case_[0], other->_impl_._oneof_case_[0]); | |||
| } | |||
| ::PROTOBUF_NAMESPACE_ID::Metadata SendMsg::GetMetadata() const | |||
| @@ -839,6 +839,13 @@ namespace protobuf | |||
| { | |||
| return *internal_default_instance(); | |||
| } | |||
| enum MessageCase | |||
| { | |||
| kTextMessage = 3, | |||
| kBinaryMessage = 4, | |||
| MESSAGE_NOT_SET = 0, | |||
| }; | |||
| static inline const SendMsg* internal_default_instance() | |||
| { | |||
| return reinterpret_cast<const SendMsg*>( | |||
| @@ -938,25 +945,11 @@ namespace protobuf | |||
| enum : int | |||
| { | |||
| kMessageFieldNumber = 3, | |||
| kPlayerIdFieldNumber = 1, | |||
| kToPlayerIdFieldNumber = 2, | |||
| kTextMessageFieldNumber = 3, | |||
| kBinaryMessageFieldNumber = 4, | |||
| }; | |||
| // string message = 3; | |||
| void clear_message(); | |||
| const std::string& message() const; | |||
| template<typename ArgT0 = const std::string&, typename... ArgT> | |||
| void set_message(ArgT0&& arg0, ArgT... args); | |||
| std::string* mutable_message(); | |||
| PROTOBUF_NODISCARD std::string* release_message(); | |||
| void set_allocated_message(std::string* message); | |||
| private: | |||
| const std::string& _internal_message() const; | |||
| inline PROTOBUF_ALWAYS_INLINE void _internal_set_message(const std::string& value); | |||
| std::string* _internal_mutable_message(); | |||
| public: | |||
| // int64 player_id = 1; | |||
| void clear_player_id(); | |||
| int64_t player_id() const; | |||
| @@ -977,10 +970,59 @@ namespace protobuf | |||
| void _internal_set_to_player_id(int64_t value); | |||
| public: | |||
| // string text_message = 3; | |||
| bool has_text_message() const; | |||
| private: | |||
| bool _internal_has_text_message() const; | |||
| public: | |||
| void clear_text_message(); | |||
| const std::string& text_message() const; | |||
| template<typename ArgT0 = const std::string&, typename... ArgT> | |||
| void set_text_message(ArgT0&& arg0, ArgT... args); | |||
| std::string* mutable_text_message(); | |||
| PROTOBUF_NODISCARD std::string* release_text_message(); | |||
| void set_allocated_text_message(std::string* text_message); | |||
| private: | |||
| const std::string& _internal_text_message() const; | |||
| inline PROTOBUF_ALWAYS_INLINE void _internal_set_text_message(const std::string& value); | |||
| std::string* _internal_mutable_text_message(); | |||
| public: | |||
| // bytes binary_message = 4; | |||
| bool has_binary_message() const; | |||
| private: | |||
| bool _internal_has_binary_message() const; | |||
| public: | |||
| void clear_binary_message(); | |||
| const std::string& binary_message() const; | |||
| template<typename ArgT0 = const std::string&, typename... ArgT> | |||
| void set_binary_message(ArgT0&& arg0, ArgT... args); | |||
| std::string* mutable_binary_message(); | |||
| PROTOBUF_NODISCARD std::string* release_binary_message(); | |||
| void set_allocated_binary_message(std::string* binary_message); | |||
| private: | |||
| const std::string& _internal_binary_message() const; | |||
| inline PROTOBUF_ALWAYS_INLINE void _internal_set_binary_message(const std::string& value); | |||
| std::string* _internal_mutable_binary_message(); | |||
| public: | |||
| void clear_message(); | |||
| MessageCase message_case() const; | |||
| // @@protoc_insertion_point(class_scope:protobuf.SendMsg) | |||
| private: | |||
| class _Internal; | |||
| void set_has_text_message(); | |||
| void set_has_binary_message(); | |||
| inline bool has_message() const; | |||
| inline void clear_has_message(); | |||
| template<typename T> | |||
| friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; | |||
| @@ -988,10 +1030,20 @@ namespace protobuf | |||
| typedef void DestructorSkippable_; | |||
| struct Impl_ | |||
| { | |||
| ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr message_; | |||
| int64_t player_id_; | |||
| int64_t to_player_id_; | |||
| union MessageUnion | |||
| { | |||
| constexpr MessageUnion() : | |||
| _constinit_{} | |||
| { | |||
| } | |||
| ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized _constinit_; | |||
| ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr text_message_; | |||
| ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr binary_message_; | |||
| } message_; | |||
| mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; | |||
| uint32_t _oneof_case_[1]; | |||
| }; | |||
| union | |||
| { | |||
| @@ -2151,63 +2203,216 @@ namespace protobuf | |||
| // @@protoc_insertion_point(field_set:protobuf.SendMsg.to_player_id) | |||
| } | |||
| // string message = 3; | |||
| inline void SendMsg::clear_message() | |||
| // string text_message = 3; | |||
| inline bool SendMsg::_internal_has_text_message() const | |||
| { | |||
| return message_case() == kTextMessage; | |||
| } | |||
| inline bool SendMsg::has_text_message() const | |||
| { | |||
| return _internal_has_text_message(); | |||
| } | |||
| inline void SendMsg::set_has_text_message() | |||
| { | |||
| _impl_._oneof_case_[0] = kTextMessage; | |||
| } | |||
| inline void SendMsg::clear_text_message() | |||
| { | |||
| _impl_.message_.ClearToEmpty(); | |||
| if (_internal_has_text_message()) | |||
| { | |||
| _impl_.message_.text_message_.Destroy(); | |||
| clear_has_message(); | |||
| } | |||
| } | |||
| inline const std::string& SendMsg::message() const | |||
| inline const std::string& SendMsg::text_message() const | |||
| { | |||
| // @@protoc_insertion_point(field_get:protobuf.SendMsg.message) | |||
| return _internal_message(); | |||
| // @@protoc_insertion_point(field_get:protobuf.SendMsg.text_message) | |||
| return _internal_text_message(); | |||
| } | |||
| template<typename ArgT0, typename... ArgT> | |||
| inline PROTOBUF_ALWAYS_INLINE void SendMsg::set_message(ArgT0&& arg0, ArgT... args) | |||
| inline void SendMsg::set_text_message(ArgT0&& arg0, ArgT... args) | |||
| { | |||
| _impl_.message_.Set(static_cast<ArgT0&&>(arg0), args..., GetArenaForAllocation()); | |||
| // @@protoc_insertion_point(field_set:protobuf.SendMsg.message) | |||
| if (!_internal_has_text_message()) | |||
| { | |||
| clear_message(); | |||
| set_has_text_message(); | |||
| _impl_.message_.text_message_.InitDefault(); | |||
| } | |||
| _impl_.message_.text_message_.Set(static_cast<ArgT0&&>(arg0), args..., GetArenaForAllocation()); | |||
| // @@protoc_insertion_point(field_set:protobuf.SendMsg.text_message) | |||
| } | |||
| inline std::string* SendMsg::mutable_message() | |||
| inline std::string* SendMsg::mutable_text_message() | |||
| { | |||
| std::string* _s = _internal_mutable_message(); | |||
| // @@protoc_insertion_point(field_mutable:protobuf.SendMsg.message) | |||
| std::string* _s = _internal_mutable_text_message(); | |||
| // @@protoc_insertion_point(field_mutable:protobuf.SendMsg.text_message) | |||
| return _s; | |||
| } | |||
| inline const std::string& SendMsg::_internal_message() const | |||
| inline const std::string& SendMsg::_internal_text_message() const | |||
| { | |||
| return _impl_.message_.Get(); | |||
| if (_internal_has_text_message()) | |||
| { | |||
| return _impl_.message_.text_message_.Get(); | |||
| } | |||
| return ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(); | |||
| } | |||
| inline void SendMsg::_internal_set_message(const std::string& value) | |||
| inline void SendMsg::_internal_set_text_message(const std::string& value) | |||
| { | |||
| _impl_.message_.Set(value, GetArenaForAllocation()); | |||
| if (!_internal_has_text_message()) | |||
| { | |||
| clear_message(); | |||
| set_has_text_message(); | |||
| _impl_.message_.text_message_.InitDefault(); | |||
| } | |||
| _impl_.message_.text_message_.Set(value, GetArenaForAllocation()); | |||
| } | |||
| inline std::string* SendMsg::_internal_mutable_message() | |||
| inline std::string* SendMsg::_internal_mutable_text_message() | |||
| { | |||
| return _impl_.message_.Mutable(GetArenaForAllocation()); | |||
| if (!_internal_has_text_message()) | |||
| { | |||
| clear_message(); | |||
| set_has_text_message(); | |||
| _impl_.message_.text_message_.InitDefault(); | |||
| } | |||
| return _impl_.message_.text_message_.Mutable(GetArenaForAllocation()); | |||
| } | |||
| inline std::string* SendMsg::release_message() | |||
| inline std::string* SendMsg::release_text_message() | |||
| { | |||
| // @@protoc_insertion_point(field_release:protobuf.SendMsg.message) | |||
| return _impl_.message_.Release(); | |||
| // @@protoc_insertion_point(field_release:protobuf.SendMsg.text_message) | |||
| if (_internal_has_text_message()) | |||
| { | |||
| clear_has_message(); | |||
| return _impl_.message_.text_message_.Release(); | |||
| } | |||
| else | |||
| { | |||
| return nullptr; | |||
| } | |||
| } | |||
| inline void SendMsg::set_allocated_text_message(std::string* text_message) | |||
| { | |||
| if (has_message()) | |||
| { | |||
| clear_message(); | |||
| } | |||
| if (text_message != nullptr) | |||
| { | |||
| set_has_text_message(); | |||
| _impl_.message_.text_message_.InitAllocated(text_message, GetArenaForAllocation()); | |||
| } | |||
| // @@protoc_insertion_point(field_set_allocated:protobuf.SendMsg.text_message) | |||
| } | |||
| // bytes binary_message = 4; | |||
| inline bool SendMsg::_internal_has_binary_message() const | |||
| { | |||
| return message_case() == kBinaryMessage; | |||
| } | |||
| inline bool SendMsg::has_binary_message() const | |||
| { | |||
| return _internal_has_binary_message(); | |||
| } | |||
| inline void SendMsg::set_has_binary_message() | |||
| { | |||
| _impl_._oneof_case_[0] = kBinaryMessage; | |||
| } | |||
| inline void SendMsg::clear_binary_message() | |||
| { | |||
| if (_internal_has_binary_message()) | |||
| { | |||
| _impl_.message_.binary_message_.Destroy(); | |||
| clear_has_message(); | |||
| } | |||
| } | |||
| inline const std::string& SendMsg::binary_message() const | |||
| { | |||
| // @@protoc_insertion_point(field_get:protobuf.SendMsg.binary_message) | |||
| return _internal_binary_message(); | |||
| } | |||
| template<typename ArgT0, typename... ArgT> | |||
| inline void SendMsg::set_binary_message(ArgT0&& arg0, ArgT... args) | |||
| { | |||
| if (!_internal_has_binary_message()) | |||
| { | |||
| clear_message(); | |||
| set_has_binary_message(); | |||
| _impl_.message_.binary_message_.InitDefault(); | |||
| } | |||
| _impl_.message_.binary_message_.SetBytes(static_cast<ArgT0&&>(arg0), args..., GetArenaForAllocation()); | |||
| // @@protoc_insertion_point(field_set:protobuf.SendMsg.binary_message) | |||
| } | |||
| inline std::string* SendMsg::mutable_binary_message() | |||
| { | |||
| std::string* _s = _internal_mutable_binary_message(); | |||
| // @@protoc_insertion_point(field_mutable:protobuf.SendMsg.binary_message) | |||
| return _s; | |||
| } | |||
| inline const std::string& SendMsg::_internal_binary_message() const | |||
| { | |||
| if (_internal_has_binary_message()) | |||
| { | |||
| return _impl_.message_.binary_message_.Get(); | |||
| } | |||
| return ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(); | |||
| } | |||
| inline void SendMsg::_internal_set_binary_message(const std::string& value) | |||
| { | |||
| if (!_internal_has_binary_message()) | |||
| { | |||
| clear_message(); | |||
| set_has_binary_message(); | |||
| _impl_.message_.binary_message_.InitDefault(); | |||
| } | |||
| _impl_.message_.binary_message_.Set(value, GetArenaForAllocation()); | |||
| } | |||
| inline std::string* SendMsg::_internal_mutable_binary_message() | |||
| { | |||
| if (!_internal_has_binary_message()) | |||
| { | |||
| clear_message(); | |||
| set_has_binary_message(); | |||
| _impl_.message_.binary_message_.InitDefault(); | |||
| } | |||
| return _impl_.message_.binary_message_.Mutable(GetArenaForAllocation()); | |||
| } | |||
| inline void SendMsg::set_allocated_message(std::string* message) | |||
| inline std::string* SendMsg::release_binary_message() | |||
| { | |||
| if (message != nullptr) | |||
| // @@protoc_insertion_point(field_release:protobuf.SendMsg.binary_message) | |||
| if (_internal_has_binary_message()) | |||
| { | |||
| clear_has_message(); | |||
| return _impl_.message_.binary_message_.Release(); | |||
| } | |||
| else | |||
| { | |||
| return nullptr; | |||
| } | |||
| } | |||
| inline void SendMsg::set_allocated_binary_message(std::string* binary_message) | |||
| { | |||
| if (has_message()) | |||
| { | |||
| clear_message(); | |||
| } | |||
| _impl_.message_.SetAllocated(message, GetArenaForAllocation()); | |||
| #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING | |||
| if (_impl_.message_.IsDefault()) | |||
| if (binary_message != nullptr) | |||
| { | |||
| _impl_.message_.Set("", GetArenaForAllocation()); | |||
| set_has_binary_message(); | |||
| _impl_.message_.binary_message_.InitAllocated(binary_message, GetArenaForAllocation()); | |||
| } | |||
| #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING | |||
| // @@protoc_insertion_point(field_set_allocated:protobuf.SendMsg.message) | |||
| // @@protoc_insertion_point(field_set_allocated:protobuf.SendMsg.binary_message) | |||
| } | |||
| inline bool SendMsg::has_message() const | |||
| { | |||
| return message_case() != MESSAGE_NOT_SET; | |||
| } | |||
| inline void SendMsg::clear_has_message() | |||
| { | |||
| _impl_._oneof_case_[0] = MESSAGE_NOT_SET; | |||
| } | |||
| inline SendMsg::MessageCase SendMsg::message_case() const | |||
| { | |||
| return SendMsg::MessageCase(_impl_._oneof_case_[0]); | |||
| } | |||
| // ------------------------------------------------------------------- | |||
| // AttackMsg | |||
| @@ -25,8 +25,6 @@ | |||
| #include <grpcpp/impl/codegen/stub_options.h> | |||
| #include <grpcpp/impl/codegen/sync_stream.h> | |||
| #undef SendMessage | |||
| namespace protobuf | |||
| { | |||
| @@ -2,7 +2,7 @@ import PyAPI.structures as THUAI6 | |||
| from PyAPI.Interface import ILogic, IStudentAPI, ITrickerAPI, IGameTimer, IAI | |||
| from math import pi | |||
| from concurrent.futures import ThreadPoolExecutor, Future | |||
| from typing import List, cast, Tuple | |||
| from typing import List, cast, Tuple, Union | |||
| class StudentAPI(IStudentAPI, IGameTimer): | |||
| @@ -68,13 +68,13 @@ class StudentAPI(IStudentAPI, IGameTimer): | |||
| # 消息相关,接收消息时无消息则返回(-1, '') | |||
| def SendMessage(self, toID: int, message: str) -> Future[bool]: | |||
| def SendMessage(self, toID: int, message: Union[str, bytes]) -> Future[bool]: | |||
| return self.__pool.submit(self.__logic.SendMessage, toID, message) | |||
| def HaveMessage(self) -> bool: | |||
| return self.__logic.HaveMessage() | |||
| def GetMessage(self) -> Tuple[int, str]: | |||
| def GetMessage(self) -> Tuple[int, Union[str, bytes]]: | |||
| return self.__logic.GetMessage() | |||
| # 等待下一帧 | |||
| @@ -244,13 +244,13 @@ class TrickerAPI(ITrickerAPI, IGameTimer): | |||
| # 消息相关,接收消息时无消息则返回(-1, '') | |||
| def SendMessage(self, toID: int, message: str) -> Future[bool]: | |||
| def SendMessage(self, toID: int, message: Union[str, bytes]) -> Future[bool]: | |||
| return self.__pool.submit(self.__logic.SendMessage, toID, message) | |||
| def HaveMessage(self) -> bool: | |||
| return self.__logic.HaveMessage() | |||
| def GetMessage(self) -> Tuple[int, str]: | |||
| def GetMessage(self) -> Tuple[int, Union[str, bytes]]: | |||
| return self.__logic.GetMessage() | |||
| # 等待下一帧 | |||
| @@ -7,6 +7,8 @@ import proto.Message2Clients_pb2 as Message2Clients | |||
| import threading | |||
| import grpc | |||
| from typing import Union | |||
| # 使用gRPC的异步来减少通信对于选手而言损失的时间,而gRPC的return值有result()方法,故若连接错误时也应当返回一个具有result()方法的对象,使用此处的ErrorHandler类来实现 | |||
| class BoolErrorHandler(IErrorHandler): | |||
| @@ -69,7 +71,7 @@ class Communication: | |||
| else: | |||
| return useResult.act_success | |||
| def SendMessage(self, toID: int, message: str, playerID: int) -> bool: | |||
| def SendMessage(self, toID: int, message: Union[str, bytes], playerID: int) -> bool: | |||
| try: | |||
| sendResult = self.__THUAI6Stub.SendMessage( | |||
| THUAI62Proto.THUAI62ProtobufSend(message, toID, playerID)) | |||
| @@ -1,6 +1,6 @@ | |||
| from math import pi | |||
| from concurrent.futures import ThreadPoolExecutor, Future | |||
| from typing import List, cast, Tuple | |||
| from typing import List, cast, Tuple, Union | |||
| import logging | |||
| import os | |||
| import datetime | |||
| @@ -216,7 +216,7 @@ class StudentDebugAPI(IStudentAPI, IGameTimer): | |||
| # 消息相关,接收消息时无消息则返回(-1, '') | |||
| def SendMessage(self, toID: int, message: str) -> Future[bool]: | |||
| def SendMessage(self, toID: int, message: Union[str, bytes]) -> Future[bool]: | |||
| self.__logger.info( | |||
| f"SendMessage: toID = {toID}, message = {message}, called at {self.__GetTime()}ms") | |||
| @@ -238,7 +238,7 @@ class StudentDebugAPI(IStudentAPI, IGameTimer): | |||
| f"HaveMessage: failed at {self.__GetTime()}ms") | |||
| return result | |||
| def GetMessage(self) -> Tuple[int, str]: | |||
| def GetMessage(self) -> Tuple[int, Union[str, bytes]]: | |||
| self.__logger.info( | |||
| f"GetMessage: called at {self.__GetTime()}ms") | |||
| result = self.__logic.GetMessage() | |||
| @@ -671,7 +671,7 @@ class TrickerDebugAPI(ITrickerAPI, IGameTimer): | |||
| # 消息相关,接收消息时无消息则返回(-1, '') | |||
| def SendMessage(self, toID: int, message: str) -> Future[bool]: | |||
| def SendMessage(self, toID: int, message: Union[str, bytes]) -> Future[bool]: | |||
| self.__logger.info( | |||
| f"SendMessage: toID = {toID}, message = {message}, called at {self.__GetTime()}ms") | |||
| @@ -693,7 +693,7 @@ class TrickerDebugAPI(ITrickerAPI, IGameTimer): | |||
| f"HaveMessage: failed at {self.__GetTime()}ms") | |||
| return result | |||
| def GetMessage(self) -> Tuple[int, str]: | |||
| def GetMessage(self) -> Tuple[int, Union[str, bytes]]: | |||
| self.__logger.info( | |||
| f"GetMessage: called at {self.__GetTime()}ms") | |||
| result = self.__logic.GetMessage() | |||
| @@ -85,7 +85,7 @@ class ILogic(metaclass=ABCMeta): | |||
| pass | |||
| @abstractmethod | |||
| def SendMessage(self, toID: int, message: str) -> bool: | |||
| def SendMessage(self, toID: int, message: Union[str, bytes]) -> bool: | |||
| pass | |||
| @abstractmethod | |||
| @@ -235,7 +235,7 @@ class IAPI(metaclass=ABCMeta): | |||
| # 消息相关,接收消息时无消息则返回(-1, '') | |||
| @abstractmethod | |||
| def SendMessage(self, toID: int, message: str) -> Future[bool]: | |||
| def SendMessage(self, toID: int, message: Union[str, bytes]) -> Future[bool]: | |||
| pass | |||
| @abstractmethod | |||
| @@ -188,7 +188,7 @@ class Logic(ILogic): | |||
| self.__logger.debug("Called UseSkill") | |||
| return self.__comm.UseSkill(skillID, self.__playerID) | |||
| def SendMessage(self, toID: int, message: str) -> bool: | |||
| def SendMessage(self, toID: int, message: Union[str, bytes]) -> bool: | |||
| self.__logger.debug("Called SendMessage") | |||
| return self.__comm.SendMessage(toID, message, self.__playerID) | |||
| @@ -196,7 +196,7 @@ class Logic(ILogic): | |||
| self.__logger.debug("Called HaveMessage") | |||
| return not self.__messageQueue.empty() | |||
| def GetMessage(self) -> Tuple[int, str]: | |||
| def GetMessage(self) -> Tuple[int, Union[str, bytes]]: | |||
| self.__logger.debug("Called GetMessage") | |||
| if self.__messageQueue.empty(): | |||
| self.__logger.warning("Message queue is empty!") | |||
| @@ -314,13 +314,13 @@ class Logic(ILogic): | |||
| else: | |||
| self.__logger.error("Unknown GameState!") | |||
| continue | |||
| self.__AILoop = False | |||
| with self.__cvBuffer: | |||
| self.__bufferUpdated = True | |||
| self.__counterBuffer = -1 | |||
| self.__cvBuffer.notify() | |||
| self.__logger.info("Game End!") | |||
| self.__logger.info("Message thread end!") | |||
| self.__AILoop = False | |||
| threading.Thread(target=messageThread).start() | |||
| @@ -438,9 +438,16 @@ class Logic(ILogic): | |||
| self.__logger.debug("Update Gate!") | |||
| elif item.WhichOneof("message_of_obj") == "news_message": | |||
| if item.news_message.to_id == self.__playerID: | |||
| self.__messageQueue.put( | |||
| (item.news_message.from_id, item.news_message.news)) | |||
| self.__logger.debug("Add News!") | |||
| if item.news_message.WhichOneof("news") == "text_message": | |||
| self.__messageQueue.put( | |||
| (item.news_message.from_id, item.news_message.text_message)) | |||
| self.__logger.debug("Add News!") | |||
| elif item.news_message.WhichOneof("news") == "binary_message": | |||
| self.__messageQueue.put( | |||
| (item.news_message.from_id, item.news_message.binary_message)) | |||
| self.__logger.debug("Add News!") | |||
| else: | |||
| self.__logger.error("Unknown News!") | |||
| else: | |||
| self.__logger.debug( | |||
| "Unknown Message!") | |||
| @@ -12,6 +12,7 @@ import argparse | |||
| import platform | |||
| import PyAPI.structures as THUAI6 | |||
| def PrintWelcomeString() -> None: | |||
| # Generated by http://www.network-science.de/ascii/ with font "standard" | |||
| welcomeString = """ | |||
| @@ -32,6 +33,7 @@ def PrintWelcomeString() -> None: | |||
| """ | |||
| print(welcomeString) | |||
| def THUAI6Main(argv: List[str], AIBuilder: Callable) -> None: | |||
| pID: int = 0 | |||
| sIP: str = "127.0.0.1" | |||
| @@ -2,7 +2,7 @@ import proto.MessageType_pb2 as MessageType | |||
| import proto.Message2Server_pb2 as Message2Server | |||
| import proto.Message2Clients_pb2 as Message2Clients | |||
| import PyAPI.structures as THUAI6 | |||
| from typing import Final, List | |||
| from typing import Final, List, Union | |||
| numOfGridPerCell: Final[int] = 1000 | |||
| @@ -350,8 +350,11 @@ class THUAI62Proto(NoInstance): | |||
| return Message2Server.PropMsg(player_id=id, prop_type=THUAI62Proto.propTypeDict[prop]) | |||
| @ staticmethod | |||
| def THUAI62ProtobufSend(msg: str, toID: int, id: int) -> Message2Server.SendMsg: | |||
| return Message2Server.SendMsg(player_id=id, to_player_id=toID, message=msg) | |||
| def THUAI62ProtobufSend(msg: Union[str, bytes], toID: int, id: int) -> Message2Server.SendMsg: | |||
| if isinstance(msg, str): | |||
| return Message2Server.SendMsg(player_id=id, to_player_id=toID, text_message=msg) | |||
| elif isinstance(msg, bytes): | |||
| return Message2Server.SendMsg(player_id=id, to_player_id=toID, binary_message=msg) | |||
| @ staticmethod | |||
| def THUAI62ProtobufAttack(angle: float, id: int) -> Message2Server.AttackMsg: | |||
| @@ -1,7 +1,7 @@ | |||
| #!/usr/bin/env bash | |||
| python PyAPI/main.py -I 172.22.32.1 -P 8888 -p 0& | |||
| python PyAPI/main.py -I 172.22.32.1 -P 8888 -p 0 -d -o& | |||
| # python PyAPI/main.py -I 172.22.32.1 -P 8888 -p 1 -o& | |||
| # python PyAPI/main.py -I 172.22.32.1 -P 8888 -p 2& | |||
| # python PyAPI/main.py -I 172.22.32.1 -P 8888 -p 3& | |||
| python PyAPI/main.py -I 172.22.32.1 -P 8888 -p 4 -d& | |||
| # python PyAPI/main.py -I 172.22.32.1 -P 8888 -p 4& | |||
| @@ -143,7 +143,11 @@ message MessageOfMap | |||
| message MessageOfNews | |||
| { | |||
| string news = 1; | |||
| oneof news // 一条新闻 | |||
| { | |||
| string text_message = 1; | |||
| bytes binary_message = 4; | |||
| } | |||
| int64 from_id = 2; | |||
| int64 to_id = 3; | |||
| } | |||
| @@ -32,7 +32,12 @@ message SendMsg | |||
| { | |||
| int64 player_id = 1; | |||
| int64 to_player_id = 2; | |||
| string message = 3; | |||
| oneof message | |||
| { | |||
| string text_message = 3; | |||
| bytes binary_message = 4; | |||
| } | |||
| } | |||
| message AttackMsg // 相当于攻击 | |||