add send() function to client

This commit is contained in:
2022-04-26 19:31:09 +02:00
parent 7c76691df7
commit 06b00843d2
4 changed files with 25 additions and 50 deletions

View File

@@ -16,7 +16,18 @@ void run_client() {
spdlog::info("Running client...");
commons::client s(io_context, boost::asio::ip::make_address("0.0.0.0"), 9000,
0);
s.init();
for (int i = 0; i < 100; ++i) {
auto msg = std::make_shared<commons::protocol::draw_pixel>();
msg->color = commons::protocol::vec3{i, i, i};
// used as lifetime expansion so that msg doesnt go out of scope till it
// actually was sent
s.send(msg->serialize(),
std::bind(&commons::protocol::generic_message_base::handle_sent, msg,
std::placeholders::_1));
}
io_context.run();
}