From c37bd3e34f5840773949bb55848cda3af6688d20 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Wed, 5 Mar 2025 23:44:56 +0800 Subject: refactor: logging system --- src/session.hpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/session.hpp') diff --git a/src/session.hpp b/src/session.hpp index 9dc3f0f..0c5e4f9 100644 --- a/src/session.hpp +++ b/src/session.hpp @@ -1,6 +1,7 @@ #pragma once #include "FileDescriptor.hpp" +#include "format.hpp" #include class CSession { @@ -15,9 +16,11 @@ class CSession { std::string getName() const; bool isValid() const; SRecvData read(); - SRecvData read(std::string &msg); - bool write(const std::string &msg) const; - void run(); + SRecvData read(const std::string &msg); + bool write(const std::string &msg, eFormatType type) const; + template + bool write(eFormatType type, std::format_string fmt, Args &&...args) const; + void run(); private: enum eEventType { @@ -31,6 +34,7 @@ class CSession { void onConnect() const; void onDisconnect() const; void onErrno(eEventType) const; - void onRecv(SRecvData &data) const; + void onRecv(const SRecvData &data) const; + void onSend(const std::string &msg) const; friend class CSessionManager; }; -- cgit v1.2.3