From b46ba43e06aba714abc0afb29566a56d69891691 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Mon, 16 Jun 2025 19:25:57 +0800 Subject: fix!: create new client without SP(this) param API: removed run(), use newClient() to accept a new client, now returning a WP of the client instance API: allow all cb to return std::any --- include/libsock/server/client.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'include/libsock/server') diff --git a/include/libsock/server/client.hpp b/include/libsock/server/client.hpp index eb528a2..6a5aa88 100644 --- a/include/libsock/server/client.hpp +++ b/include/libsock/server/client.hpp @@ -2,6 +2,7 @@ #include "../types.hpp" #include "server.hpp" +#include #include #include #include @@ -42,9 +43,9 @@ 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); @@ -81,9 +82,8 @@ class Clients { Clients(); ~Clients(); - void newClient(std::optional> cb = std::nullopt); + WP newClient(std::optional)>> cb = std::nullopt); - void run(std::optional> cb = std::nullopt); 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 = ""); void addClient(const Client &client); -- cgit v1.2.3