diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-06-12 20:01:31 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-06-12 20:01:48 +0800 |
| commit | e591313575c63810bb9683cbad4500df1cb50cf1 (patch) | |
| tree | 05d97e22cfcb76d3398e0a45172045b7c0c82779 /src/session.cpp | |
| parent | 9d1452447481d45344a1e33446ad9a418e9ea64f (diff) | |
fix(Makefile): -O0 builds
Diffstat (limited to 'src/session.cpp')
| -rw-r--r-- | src/session.cpp | 59 |
1 files changed, 31 insertions, 28 deletions
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 <typename... Args> -bool CSession::write(std::format_string<Args...> fmt, Args &&...args) { - if (m_bDeaf) - return false; - return write(NONE, fmt, std::forward<Args>(args)...); -} - -template <typename... Args> -bool CSession::write(eFormatType type, std::format_string<Args...> fmt, Args &&...args) { - if (m_bDeaf) - return false; - - std::string msg = NFormatter::fmt(type, fmt, std::forward<Args>(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<std::jthread, std::shared_ptr<CSession>> *self) { this->self = self; } + +template <typename... Args> +bool CSession::write(std::format_string<Args...> fmt, Args &&...args) { + if (m_bDeaf) + return false; + return write(NONE, fmt, std::forward<Args>(args)...); +} + +template <typename... Args> +bool CSession::write(eFormatType type, std::format_string<Args...> fmt, Args &&...args) { + if (m_bDeaf) + return false; + + std::string msg = NFormatter::fmt(type, fmt, std::forward<Args>(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<const std::string &>(std::format_string<const std::string &>, const std::string &); +template bool CSession::write<const std::string &>(eFormatType, std::format_string<const std::string &>, const std::string &); |
