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 --- src/server/client.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/server/client.cpp') diff --git a/src/server/client.cpp b/src/server/client.cpp index 5de8b79..f8dc1ca 100644 --- a/src/server/client.cpp +++ b/src/server/client.cpp @@ -75,8 +75,7 @@ void SRecvData::sanitize() { data.clear(); } -UP -Client::read(std::optional> cb) { +UP Client::read(std::optional> cb) { auto recvData = std::make_unique(); recvData->data.resize(recvData->size); @@ -99,11 +98,10 @@ Client::read(std::optional> cb) { return recvData; } -UP -Client::read(const std::string &msg, std::optional> cb) { +UP Client::read(const std::string &msg, std::optional> cb) { write("{}", msg); m_szReading = msg; - return read(); + return read(cb); } void Client::run() { @@ -126,7 +124,7 @@ bool Client::isValid() { err == 0; } -bool Client::write(const std::string &msg, std::optional> cb) { +bool Client::write(const std::string &msg, std::optional> cb) { const auto r = write("{}", msg); if (cb) { auto recvData = std::make_unique(); -- cgit v1.2.3