Processes control messages (e.g., session, ping)
- Parameters
-
| client_fd | Client file descriptor |
| message | Control message string |
Definition at line 324 of file Server.cpp.
325{
326 if (message.starts_with("session ")) {
327 std::string session_id(message.substr(8));
329 if (!
send_message(client_fd, R
"({"status":"success","message":"Session ID set to ')" + session_id + R"('"})")) {
330 LILA_WARN(Emitter::SERVER, "Failed to send session confirmation to client fd " + std::to_string(client_fd));
331 }
332 } else if (message.starts_with("ping")) {
333 if (!
send_message(client_fd, R
"({"status":"success","message":"pong"})")) {
334 LILA_WARN(Emitter::SERVER, "Failed to send pong to client fd " + std::to_string(client_fd));
335 }
336 } else {
337 if (!
send_message(client_fd,
"{\"status\":\"error\",\"message\":\"Unknown command: " + std::string(message) +
"\"}")) {
338 LILA_WARN(Emitter::SERVER,
"Failed to send unknown command error to client fd " + std::to_string(client_fd));
339 }
340 }
341}
void set_client_session(int client_fd, std::string session_id)
Sets the session ID for a client.
bool send_message(int client_fd, std::string_view message)
Sends a message to a client.
References LILA_WARN, send_message(), and set_client_session().
Referenced by handle_client().