mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 21:42:43 +00:00 
			
		
		
		
	 4a37bec27c
			
		
	
	
		4a37bec27c
		
	
	
	
	
		
			
			This matches what we're already calling the server-side subclasses better, though we'll probably want to find some better names for the client-side classes eventually.
		
			
				
	
	
		
			22 lines
		
	
	
	
		
			654 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
	
		
			654 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| #include "ASEventLoop.h"
 | |
| #include "ASClientConnection.h"
 | |
| #include <sys/socket.h>
 | |
| #include <sys/types.h>
 | |
| #include <unistd.h>
 | |
| 
 | |
| ASEventLoop::ASEventLoop()
 | |
|     : m_server(CLocalServer::construct())
 | |
| {
 | |
|     bool ok = m_server->take_over_from_system_server();
 | |
|     ASSERT(ok);
 | |
|     m_server->on_ready_to_accept = [this] {
 | |
|         auto client_socket = m_server->accept();
 | |
|         if (!client_socket) {
 | |
|             dbg() << "AudioServer: accept failed.";
 | |
|             return;
 | |
|         }
 | |
|         static int s_next_client_id = 0;
 | |
|         int client_id = ++s_next_client_id;
 | |
|         new_client_connection<ASClientConnection>(*client_socket, client_id, m_mixer);
 | |
|     };
 | |
| }
 |