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:
Kieran Kihn
2025-12-04 17:17:32 +08:00
parent 8335769cc8
commit ea87fca1fd

View File

@@ -63,6 +63,10 @@ namespace UNO::NETWORK {
auto msg = std::make_shared<std::string>(message); 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)}; 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 } // namespace UNO::NETWORK