mirror of
https://github.com/kierankihn/uno-game.git
synced 2025-12-27 02:13:18 +08:00
fix(network): ensure write continuation upon successful async_write
- Added a check in `Session::doWrite` to invoke subsequent writes when the message queue is not empty.
This commit is contained in:
@@ -63,6 +63,10 @@ namespace UNO::NETWORK {
|
||||
auto msg = std::make_shared<std::string>(message);
|
||||
|
||||
std::array<asio::const_buffer, 2> buffers = {asio::buffer(length.get(), sizeof(size_t)), asio::buffer(*msg)};
|
||||
asio::async_write(socket_, buffers, [this, self = shared_from_this(), length, msg](const asio::error_code &ec, size_t) {});
|
||||
asio::async_write(socket_, buffers, [this, self = shared_from_this(), length, msg](const asio::error_code &ec, size_t) {
|
||||
if (!ec && this->messages_.empty() == false) {
|
||||
this->doWrite();
|
||||
}
|
||||
});
|
||||
}
|
||||
} // namespace UNO::NETWORK
|
||||
Reference in New Issue
Block a user