From 6b64485b40e6324caecf943d1d113cd6216d2af9 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Fri, 9 Dec 2022 11:17:52 -0500 Subject: [PATCH] LibIPC: Add a hook to MultiServer to inform owners of new clients This will allow the owner of the server to mutate the client after it has been accepted. --- Userland/Libraries/LibIPC/MultiServer.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibIPC/MultiServer.h b/Userland/Libraries/LibIPC/MultiServer.h index ce0992c5e4..6efd056d11 100644 --- a/Userland/Libraries/LibIPC/MultiServer.h +++ b/Userland/Libraries/LibIPC/MultiServer.h @@ -7,6 +7,7 @@ #pragma once #include +#include #include #include @@ -22,13 +23,18 @@ public: return adopt_nonnull_own_or_enomem(new (nothrow) MultiServer(move(server))); } + Function on_new_client; + private: explicit MultiServer(NonnullRefPtr server) : m_server(move(server)) { m_server->on_accept = [&](auto client_socket) { auto client_id = ++m_next_client_id; - (void)IPC::new_client_connection(move(client_socket), client_id); + + auto client = IPC::new_client_connection(move(client_socket), client_id); + if (on_new_client) + on_new_client(*client); }; }