105{
106 spdlog::trace("Received {} messages", recvMsgs.size());
107 replyMsgs.clear();
108
109 std::string replyBody;
110 int reply = ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL;
111 switch (*(static_cast<const uint64_t *>(recvMsgs[0].data())))
112 {
114 if (recvMsgs.size() != 2)
115 {
116 spdlog::error("Received unknown number of messages for log level change");
117 break;
118 }
119
120 spdlog::warn("Log level change request received");
121 const auto receivedMsg = std::string(static_cast<const char *>(recvMsgs[1].data()), recvMsgs[1].size());
122
123 if (receivedMsg == "v")
124 {
125 spdlog::set_level(spdlog::level::info);
126 }
127 if (receivedMsg == "vv")
128 {
129 spdlog::set_level(spdlog::level::debug);
130 }
131 if (receivedMsg == "vvv")
132 {
133 spdlog::set_level(spdlog::level::trace);
134 }
135 reply = ZMQ_EVENT_HANDSHAKE_SUCCEEDED;
136 break;
137 }
139 if (recvMsgs.size() != 1)
140 {
141 spdlog::error("Received unknown number of messages for version information");
142 break;
143 }
144
145 reply = ZMQ_EVENT_HANDSHAKE_SUCCEEDED;
146 replyBody = PROJECT_FULL_VERSION_STRING;
147 break;
148 }
150 if (recvMsgs.size() != 1)
151 {
152 spdlog::error("Received unknown number of messages for ping");
153 break;
154 }
155
156 reply = ZMQ_EVENT_HANDSHAKE_SUCCEEDED;
157 replyBody = "PONG";
158 break;
159 }
161 if (recvMsgs.size() != 1)
162 {
163 spdlog::error("Received unknown number of messages for status check");
164 break;
165 }
166
167 reply = ZMQ_EVENT_HANDSHAKE_SUCCEEDED;
168
169 std::ostringstream oss;
170 oss << "{";
172 {
173 oss << "\"" << entry.first << "\":" << (entry.second->_M_i ? "1," : "0,");
174 }
175 replyBody = oss.str();
176 replyBody.replace(replyBody.size() - 1, 1, "}");
177 break;
178 }
179
180
181
182
183
184
185
186 default:
187 spdlog::error("Unknown command received from control");
188 break;
189 }
190
191
192 replyMsgs.emplace_back(&reply, sizeof(reply));
193 replyMsgs.emplace_back(replyBody.c_str(), replyBody.size());
194
195 return reply == ZMQ_EVENT_HANDSHAKE_SUCCEEDED;
196}
std::vector< std::pair< std::string, std::shared_ptr< std::atomic_flag > > > vCheckFlag
Global variable to check if the servers are running.
constexpr uint32_t PING_PONG_ID
constexpr uint32_t VERSION_INFO_ID
constexpr uint32_t LOG_LEVEL_ID
constexpr uint32_t STATUS_CHECK_ID