mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 20:02:44 +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.
		
			
				
	
	
		
			25 lines
		
	
	
	
		
			791 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
	
		
			791 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| #include <LibCore/CEventLoop.h>
 | |
| #include <LibCore/CLocalServer.h>
 | |
| #include <LibIPC/IClientConnection.h>
 | |
| #include <ProtocolServer/HttpProtocol.h>
 | |
| #include <ProtocolServer/PSClientConnection.h>
 | |
| 
 | |
| int main(int, char**)
 | |
| {
 | |
|     CEventLoop event_loop;
 | |
|     (void)*new HttpProtocol;
 | |
|     auto server = CLocalServer::construct();
 | |
|     bool ok = server->take_over_from_system_server();
 | |
|     ASSERT(ok);
 | |
|     server->on_ready_to_accept = [&] {
 | |
|         auto client_socket = server->accept();
 | |
|         if (!client_socket) {
 | |
|             dbg() << "ProtocolServer: accept failed.";
 | |
|             return;
 | |
|         }
 | |
|         static int s_next_client_id = 0;
 | |
|         int client_id = ++s_next_client_id;
 | |
|         new_client_connection<PSClientConnection>(*client_socket, client_id);
 | |
|     };
 | |
|     return event_loop.exec();
 | |
| }
 |