Addressing some bugs regarding lifetimes and callbacks that could trigger random-ish crashed - wip

This commit is contained in:
2026-03-17 17:00:20 +01:00
parent 1136892c5d
commit 604e4ace0f
9 changed files with 92 additions and 51 deletions

View File

@@ -11,6 +11,7 @@
#include <columnlynx/common/utils.hpp>
#include <columnlynx/common/libsodium_wrapper.hpp>
#include <array>
#include <atomic>
#include <algorithm>
#include <vector>
#include <unordered_map>
@@ -89,8 +90,8 @@ namespace ColumnLynx::Net::TCP {
// TODO: Move ptrs to smart ptrs
bool mConnected = false;
bool mHandshakeComplete = false;
std::atomic<bool> mConnected{false};
std::atomic<bool> mHandshakeComplete{false};
tcp::resolver mResolver;
tcp::socket mSocket;
std::shared_ptr<MessageHandler> mHandler;

View File

@@ -39,6 +39,6 @@ namespace ColumnLynx::Net::TCP {
std::array<uint8_t, 3> mHeader{}; // [type][lenHigh][lenLow]
std::vector<uint8_t> mBody;
std::function<void(AnyMessageType, std::string)> mOnMessage;
std::function<void(asio::error_code&)> mOnDisconnect;
std::function<void(const asio::error_code&)> mOnDisconnect;
};
}