lichao
2021-05-21 11f6c600e55ca5677f93624efe44d2605cdd908d
src/topic_node.cpp
@@ -29,6 +29,11 @@
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();
@@ -143,10 +148,9 @@
   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;
   }
@@ -315,8 +319,17 @@
           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;