From f5aacb29f5f238ae9121bf43d96ad2eba361e7b7 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Wed, 18 Jun 2025 11:21:15 +0800 Subject: API(server/clients): callback fucntion for kick function --- src/server/clients.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/server/clients.cpp') diff --git a/src/server/clients.cpp b/src/server/clients.cpp index d3a9908..1a11ed7 100644 --- a/src/server/clients.cpp +++ b/src/server/clients.cpp @@ -99,7 +99,7 @@ std::vector Clients::getDatas() const { return m_vDatas; } -void Clients::kick(WP clientWeak, const bool kill, const std::string &reason) { +void Clients::kick(WP clientWeak, const bool kill, const std::string &reason, std::optional>>::iterator &)>> cb) { auto client = clientWeak.lock(); if (!client) return; @@ -108,9 +108,9 @@ void Clients::kick(WP clientWeak, const bool kill, const std::string &re if (it->second == client) { if (client && !client->getName().empty()) // this only exist when the client is registered - // not sure why the second is null, but m_name definately is since it's setted during register - // but we don't need to notify people if the client didn't even "join"/register anyways - broadcast(std::format("{} has left the chat", client->getName()), clientWeak); + // not sure why the second is null + if (cb) + (*cb)(it); if (!reason.empty()) client->write(reason); -- cgit v1.2.3