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

◆ cleanup_client()

void Lila::Server::cleanup_client ( int  client_fd)
private

Cleans up resources for a disconnected client.

Parameters
client_fdClient file descriptor

Definition at line 412 of file Server.cpp.

413{
414 std::optional<ClientInfo> client_info;
415
416 {
417 std::unique_lock lock(m_clients_mutex);
418 if (auto it = m_connected_clients.find(client_fd); it != m_connected_clients.end()) {
419 client_info = it->second;
420 m_connected_clients.erase(it);
421 }
422 }
423
424 if (client_info) {
426 m_disconnect_handler(*client_info);
427 }
428
429 m_event_bus.publish(StreamEvent { EventType::ClientDisconnected, *client_info });
430
431 LILA_INFO(Emitter::SERVER, "Client disconnected (fd: " + std::to_string(client_fd) + ")");
432 }
433
434 socket_close(client_fd);
435}
#define LILA_INFO(emitter, msg)
void publish(const StreamEvent &event)
Publish an event to all subscribers of its type.
Definition EventBus.cpp:18
ConnectionHandler m_disconnect_handler
Handler for client disconnections.
Definition Server.hpp:169
std::shared_mutex m_clients_mutex
Mutex for client map.
Definition Server.hpp:173
std::unordered_map< int, ClientInfo > m_connected_clients
Map of connected clients.
Definition Server.hpp:174
EventBus m_event_bus
Event bus for publishing server events.
Definition Server.hpp:171
static void socket_close(int fd)
Definition Server.cpp:43

References LILA_INFO, m_clients_mutex, m_connected_clients, m_disconnect_handler, m_event_bus, Lila::EventBus::publish(), and Lila::socket_close().

Referenced by handle_client().

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