Wesnothd Connection: simplify send() implementation

asio::const_buffers_1 is deprecated as of 1.66. Its replacement (const_buffer) doesn't have begin() and end() functions.
However, since (unless I'm reading this code wrong), we're dealing with a single buffer at this point, we don't need the
range constructor and can just insert the data directly into the queue via internalizer list (this also allows us to remove
the push_front call).

If we do need a range call, I think we're supposed to now use asio::buffer_sequence_begin and asio::buffer_sequence_end.
This commit is contained in:
Charles Dang 2020-12-07 01:54:58 +11:00
parent 33f60c16a9
commit 40441fecb4

View File

@ -376,10 +376,10 @@ void wesnothd_connection::send()
bytes_written_ = 0;
payload_size_ = htonl(buf_size);
boost::asio::streambuf::const_buffers_type gzipped_data = buf.data();
std::deque<boost::asio::const_buffer> bufs(gzipped_data.begin(), gzipped_data.end());
bufs.push_front(boost::asio::buffer(reinterpret_cast<const char*>(&payload_size_), 4));
std::deque<boost::asio::const_buffer> bufs {
boost::asio::buffer(reinterpret_cast<const char*>(&payload_size_), 4),
buf.data()
};
boost::asio::async_write(socket_, bufs,
std::bind(&wesnothd_connection::is_write_complete, this, std::placeholders::_1, std::placeholders::_2),