mirror of
https://github.com/kierankihn/uno-game.git
synced 2025-12-27 02:13:18 +08:00
fix(network): use shared pointer for message length in Session::read
- Updated `Session::read` to use `std::shared_ptr` for message length to ensure proper memory handling in async operations.
This commit is contained in:
@@ -27,9 +27,9 @@ namespace UNO::NETWORK {
|
||||
|
||||
void Session::read()
|
||||
{
|
||||
size_t messageLength;
|
||||
auto messageLength = std::make_shared<size_t>(0);
|
||||
asio::async_read(socket_,
|
||||
asio::buffer(&messageLength, sizeof(messageLength)),
|
||||
asio::buffer(messageLength.get(), sizeof(size_t)),
|
||||
[this, self = shared_from_this(), messageLength](const asio::error_code &ec, size_t length) {
|
||||
if (!ec) {
|
||||
if (messageLength > 0 && messageLength <= 10 * 1024 * 1024) {
|
||||
|
||||
Reference in New Issue
Block a user