From 2320470d342db4cb5ae0ae717dfc5ac94bd3f2d2 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Sat, 21 Jun 2025 21:18:28 +0800 Subject: internal(server): remove return of std::any for callbacks use bool for cases for premature return --- include/libsock/server/client.hpp | 11 +++++------ include/libsock/server/clients.hpp | 7 +++---- 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'include/libsock/server') diff --git a/include/libsock/server/client.hpp b/include/libsock/server/client.hpp index f7d9889..2549ef5 100644 --- a/include/libsock/server/client.hpp +++ b/include/libsock/server/client.hpp @@ -3,7 +3,6 @@ #include "../types.hpp" #include "clients.hpp" #include "server.hpp" -#include #include #include #include @@ -37,14 +36,14 @@ class Client { const std::string &getIp() const; bool isAdmin() const; - UP read(std::optional> cb = std::nullopt); - UP read(const std::string &msg, std::optional> cb = std::nullopt); - bool write(const std::string &msg, std::optional> cb = std::nullopt); + UP read(std::optional> cb = std::nullopt); + UP read(const std::string &msg, std::optional> cb = std::nullopt); + bool write(const std::string &msg, std::optional> cb = std::nullopt); template bool write(std::format_string fmt, Args &&...args); void resumeHistory(); - void runLoop(bool resumeHistory = true, std::optional> cb = std::nullopt); + void runLoop(bool resumeHistory = true, std::optional> cb = std::nullopt); bool isValid(); @@ -62,7 +61,7 @@ class Client { std::optional m_szReading = std::nullopt; - void recvLoop(std::optional> cb = std::nullopt); + void recvLoop(std::optional> cb = std::nullopt); friend class Clients; }; diff --git a/include/libsock/server/clients.hpp b/include/libsock/server/clients.hpp index 9e08797..d8c1921 100644 --- a/include/libsock/server/clients.hpp +++ b/include/libsock/server/clients.hpp @@ -2,7 +2,6 @@ #include "../types.hpp" #include "server.hpp" -#include #include #include #include @@ -25,14 +24,14 @@ class Clients : public std::enable_shared_from_this { static SP create(); ~Clients(); - WP newClient(std::function &)> loopFunc = [](const WP &) { return std::any(); }, SP server = pServer); + WP newClient(std::function &)> loopFunc = [](const WP &) { ; }, SP server = pServer); void broadcast(const std::string &msg, std::optional> self = std::nullopt); // second param only specified when we // want to exclude the sender - void kick(WP client, const bool kill = false, const std::string &reason = "", std::optional>>::iterator &)>> cb = std::nullopt); + void kick(WP client, const bool kill = false, const std::string &reason = "", std::optional>>::iterator &)>> cb = std::nullopt); void addClient(const Client &client); - void shutdownClients(std::optional>> &)>> cb = std::nullopt); + void shutdownClients(std::optional>> &)>> cb = std::nullopt); SP getByIp(const std::string &ip) const; std::vector> getClients() const; -- cgit v1.2.3