| | |
| | | |
| | | namespace |
| | | { |
| | | bool ValidUserSymbol(const std::string &s) |
| | | { |
| | | return !s.empty() && s[0] != '#' && s[0] != '@'; |
| | | } |
| | | |
| | | inline void AddRoute(BHMsgHead &head, const ShmSocket &sock) |
| | | { |
| | | auto route = head.add_route(); |
| | |
| | | for (auto &p : sockets_) { p->Stop(); } |
| | | } |
| | | |
| | | bool TopicNode::UniRegister(const bool internal, ProcInfo &proc, MsgCommonReply &reply_body, const int timeout_ms) |
| | | bool TopicNode::DoRegister(const bool internal, ProcInfo &proc, MsgCommonReply &reply_body, const int timeout_ms) |
| | | { |
| | | auto ValidUserProcId = [](const std::string &id) { return !id.empty() && id[0] != '#'; }; |
| | | if (!internal && !ValidUserProcId(proc.proc_id())) { |
| | | if (!internal && !ValidUserSymbol(proc.proc_id())) { |
| | | SetLastError(eInvalidInput, "invalid proc id :'" + proc.proc_id() + "'"); |
| | | return false; |
| | | } |
| | |
| | | reply.ParseBody(reply_body)); |
| | | } |
| | | |
| | | bool TopicNode::ServerRegisterRPC(MsgTopicList &topics, MsgCommonReply &reply_body, const int timeout_ms) |
| | | bool TopicNode::DoServerRegisterRPC(const bool internal, MsgTopicList &topics, MsgCommonReply &reply_body, const int timeout_ms) |
| | | { |
| | | if (!internal) { |
| | | for (auto &&topic : topics.topic_list()) { |
| | | if (!ValidUserSymbol(topic)) { |
| | | SetLastError(eInvalidInput, "invalid user topic :'" + topic + "'"); |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (!IsOnline()) { |
| | | SetLastError(eNotRegistered, kErrMsgNotRegistered); |
| | | return false; |