MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ process_control_message()

void Lila::Server::process_control_message ( int  client_fd,
std::string_view  message 
)
private

Processes control messages (e.g., session, ping)

Parameters
client_fdClient file descriptor
messageControl 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));
328 set_client_session(client_fd, session_id);
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}
#define LILA_WARN(emitter, msg)
void set_client_session(int client_fd, std::string session_id)
Sets the session ID for a client.
Definition Server.cpp:343
bool send_message(int client_fd, std::string_view message)
Sends a message to a client.
Definition Server.cpp:400

References LILA_WARN, send_message(), and set_client_session().

Referenced by handle_client().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: