From e591313575c63810bb9683cbad4500df1cb50cf1 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Thu, 12 Jun 2025 20:01:31 +0800 Subject: fix(Makefile): -O0 builds --- src/session.cpp | 59 ++++++++++++++++++++++++++++++--------------------------- src/session.hpp | 2 ++ 2 files changed, 33 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/session.cpp b/src/session.cpp index aa6147c..84f1824 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -214,34 +214,6 @@ bool CSession::isValid() { return getsockopt(m_sockfd->get(), SOL_SOCKET, SO_ERROR, &err, &size) >= 0 && err == 0; } -template -bool CSession::write(std::format_string fmt, Args &&...args) { - if (m_bDeaf) - return false; - return write(NONE, fmt, std::forward(args)...); -} - -template -bool CSession::write(eFormatType type, std::format_string fmt, Args &&...args) { - if (m_bDeaf) - return false; - - std::string msg = NFormatter::fmt(type, fmt, std::forward(args)...); - if (m_szReading) { - msg.insert(0, "\r"); - msg.append(*m_szReading); - } - - if (send(m_sockfd->get(), msg.c_str(), msg.size(), 0) < 0) { - onErrno(WRITE); - return false; - } -#ifdef DEBUG - onSend(msg); -#endif - return true; -} - bool CSession::write(const std::string &msg) { return write("{}", msg); } @@ -271,3 +243,34 @@ bool CSession::isAdmin() const { void CSession::setSelf(std::pair> *self) { this->self = self; } + +template +bool CSession::write(std::format_string fmt, Args &&...args) { + if (m_bDeaf) + return false; + return write(NONE, fmt, std::forward(args)...); +} + +template +bool CSession::write(eFormatType type, std::format_string fmt, Args &&...args) { + if (m_bDeaf) + return false; + + std::string msg = NFormatter::fmt(type, fmt, std::forward(args)...); + if (m_szReading) { + msg.insert(0, "\r"); + msg.append(*m_szReading); + } + + if (send(m_sockfd->get(), msg.c_str(), msg.size(), 0) < 0) { + onErrno(WRITE); + return false; + } +#ifdef DEBUG + onSend(msg); +#endif + return true; +} + +template bool CSession::write(std::format_string, const std::string &); +template bool CSession::write(eFormatType, std::format_string, const std::string &); diff --git a/src/session.hpp b/src/session.hpp index af5d9ee..7747c02 100644 --- a/src/session.hpp +++ b/src/session.hpp @@ -3,11 +3,13 @@ #include "FileDescriptor.hpp" #include "chatManager.hpp" #include "format.hpp" +#include #include #include #include #include #include +#include class CSession { public: -- cgit v1.2.3