summaryrefslogtreecommitdiff
path: root/Servers/AudioServer/ASEventLoop.cpp
blob: 46b0fb12f0f6035e287f64e62b0e2d655e4de312 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "ASEventLoop.h"
#include "ASClientConnection.h"
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>

ASEventLoop::ASEventLoop()
{
    unlink("/tmp/asportal");
    m_server_sock.listen("/tmp/asportal");
    m_server_sock.on_ready_to_accept = [this] {
        auto* client_socket = m_server_sock.accept();
        if (!client_socket) {
            dbg() << "AudioServer: accept failed.";
            return;
        }
        static int s_next_client_id = 0;
        int client_id = ++s_next_client_id;
        IPC::Server::new_connection_for_client<ASClientConnection>(*client_socket, client_id, m_mixer);
    };
}