#include #include #include #include #include #include "SimpleEndpoint.h" class SimpleIPCServer final : public IPC::Server::ConnectionNG, public SimpleEndpoint { C_OBJECT(SimpleIPCServer) public: SimpleIPCServer(CLocalSocket& socket, int client_id) : ConnectionNG(*this, socket, client_id) { } virtual OwnPtr handle(const Simple::ComputeSum& message) { return make(message.a() + message.b() + message.c()); } }; int main(int, char**) { CEventLoop event_loop; unlink("/tmp/simple-ipc"); CLocalServer server_sock; server_sock.listen("/tmp/simple-ipc"); server_sock.on_ready_to_accept = [&] { auto* client_socket = server_sock.accept(); ASSERT(client_socket); static int next_client_id = 0; IPC::Server::new_connection_ng_for_client(*client_socket, ++next_client_id); }; return event_loop.exec(); }