2#include <ossia/network/sockets/writers.hpp>
4#include <boost/asio/buffer.hpp>
5#include <boost/asio/error.hpp>
6#include <boost/asio/read.hpp>
7#include <boost/asio/streambuf.hpp>
8#include <boost/asio/write.hpp>
15 template <
typename Socket>
19 void write(
const char* data, std::size_t sz)
21 this->write(socket, boost::asio::buffer(data, sz));
25 void write(T& sock,
const boost::asio::const_buffer& buf)
27 boost::asio::write(sock, buf);
31 void write(multi_socket_writer<T>& sock,
const boost::asio::const_buffer& buf)
37 template <
typename Socket>
41 boost::asio::streambuf m_data;
43 explicit decoder(Socket& s)
49 decoder(
const decoder&) =
delete;
50 decoder(decoder&&) =
delete;
51 decoder& operator=(
const decoder&) =
delete;
52 decoder& operator=(decoder&&) =
delete;
56 socket.async_read_some(
57 boost::asio::mutable_buffer(m_data.prepare(1024)),
59 f = std::move(f)](boost::system::error_code ec, std::size_t sz)
mutable {
60 if(!f.validate_stream(ec))
63 auto data = (const uint8_t*)m_data.data().data();
65 receive(std::move(f));