summaryrefslogtreecommitdiff
path: root/include/libsock/server
diff options
context:
space:
mode:
Diffstat (limited to 'include/libsock/server')
-rw-r--r--include/libsock/server/client.hpp11
-rw-r--r--include/libsock/server/clients.hpp7
2 files changed, 8 insertions, 10 deletions
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 <any>
#include <format>
#include <functional>
#include <netinet/in.h>
@@ -37,14 +36,14 @@ class Client {
const std::string &getIp() const;
bool isAdmin() const;
- UP<SRecvData> read(std::optional<std::function<std::any(const SRecvData &)>> cb = std::nullopt);
- UP<SRecvData> read(const std::string &msg, std::optional<std::function<std::any(const SRecvData &)>> cb = std::nullopt);
- bool write(const std::string &msg, std::optional<std::function<std::any(const SRecvData &)>> cb = std::nullopt);
+ UP<SRecvData> read(std::optional<std::function<bool(const SRecvData &)>> cb = std::nullopt);
+ UP<SRecvData> read(const std::string &msg, std::optional<std::function<bool(const SRecvData &)>> cb = std::nullopt);
+ bool write(const std::string &msg, std::optional<std::function<bool(const SRecvData &)>> cb = std::nullopt);
template <typename... Args>
bool write(std::format_string<Args...> fmt, Args &&...args);
void resumeHistory();
- void runLoop(bool resumeHistory = true, std::optional<std::function<std::any(const SRecvData &)>> cb = std::nullopt);
+ void runLoop(bool resumeHistory = true, std::optional<std::function<bool(const SRecvData &)>> cb = std::nullopt);
bool isValid();
@@ -62,7 +61,7 @@ class Client {
std::optional<std::string> m_szReading = std::nullopt;
- void recvLoop(std::optional<std::function<std::any(const SRecvData &)>> cb = std::nullopt);
+ void recvLoop(std::optional<std::function<bool(const SRecvData &)>> 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 <any>
#include <functional>
#include <memory>
#include <optional>
@@ -25,14 +24,14 @@ class Clients : public std::enable_shared_from_this<Clients> {
static SP<Clients> create();
~Clients();
- WP<Client> newClient(std::function<std::any(const WP<Client> &)> loopFunc = [](const WP<Client> &) { return std::any(); }, SP<Server> server = pServer);
+ WP<Client> newClient(std::function<void(const WP<Client> &)> loopFunc = [](const WP<Client> &) { ; }, SP<Server> server = pServer);
void broadcast(const std::string &msg, std::optional<WP<Client>> self = std::nullopt); // second param only specified when we
// want to exclude the sender
- void kick(WP<Client> client, const bool kill = false, const std::string &reason = "", std::optional<std::function<std::any(const std::vector<std::pair<std::jthread, SP<Client>>>::iterator &)>> cb = std::nullopt);
+ void kick(WP<Client> client, const bool kill = false, const std::string &reason = "", std::optional<std::function<bool(const std::vector<std::pair<std::jthread, SP<Client>>>::iterator &)>> cb = std::nullopt);
void addClient(const Client &client);
- void shutdownClients(std::optional<std::function<std::any(const std::vector<std::pair<std::jthread, SP<Client>>> &)>> cb = std::nullopt);
+ void shutdownClients(std::optional<std::function<bool(const std::vector<std::pair<std::jthread, SP<Client>>> &)>> cb = std::nullopt);
SP<Client> getByIp(const std::string &ip) const;
std::vector<SP<Client>> getClients() const;