diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-05-20 18:33:14 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-05-20 18:33:14 +0800 |
| commit | 092965b583bd0c377ed5d9f2af0e0f4bb0548354 (patch) | |
| tree | c002b8c85a8de2ef636d931771e5800913338d5f | |
| parent | e20099b72a14242481aefc9846cadd16657132ec (diff) | |
internal: use uintptr_t of session instance for identification
| -rw-r--r-- | TODO.md | 2 | ||||
| -rw-r--r-- | src/chatManager.cpp | 1 | ||||
| -rw-r--r-- | src/chatManager.hpp | 2 | ||||
| -rw-r--r-- | src/session.cpp | 2 |
4 files changed, 5 insertions, 2 deletions
@@ -2,7 +2,7 @@ - [ ] ci unit testing - [ ] multiline buffer input/output - [ ] file upload/download -- [ ] user identifier, UUID or something, IP can duplicate, username can be .empty() +- [x] user identifier, ~UUID or something~uintptr_t of instance, IP can duplicate, username can be .empty() ## FTXUI diff --git a/src/chatManager.cpp b/src/chatManager.cpp index 96c1b0c..07dfce4 100644 --- a/src/chatManager.cpp +++ b/src/chatManager.cpp @@ -20,6 +20,7 @@ void CChatManager::newMessage(const SMessage &msg) { return; } g_pSessionManager->broadcastChat(msg); + g_pIOManager->m_vIO.push_back({.msg = msg, .log = std::nullopt}); g_pInputManager->updateIO(); } diff --git a/src/chatManager.hpp b/src/chatManager.hpp index 0f423f7..46b02de 100644 --- a/src/chatManager.hpp +++ b/src/chatManager.hpp @@ -1,6 +1,7 @@ #pragma once #include <memory> +#include <optional> #include <string> #include <vector> @@ -11,6 +12,7 @@ class CChatManager { struct SMessage { std::string msg; std::string username; + std::optional<uintptr_t> sender = std::nullopt; bool admin = false; }; void newMessage(const SMessage &msg); diff --git a/src/session.cpp b/src/session.cpp index 8a311bf..8167a91 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -249,7 +249,7 @@ bool CSession::write(const std::string &msg) { } bool CSession::writeChat(const CChatManager::SMessage &msg) { - if (m_name != msg.username) { + if ((uintptr_t)this != *msg.sender) { if (msg.admin && !m_isAdmin) return false; |
