adding client/server prototype

This commit is contained in:
2022-04-23 04:53:18 +02:00
parent 06ec89b00e
commit b7541420f1
7 changed files with 248 additions and 54 deletions

View File

@@ -1,27 +1,55 @@
#include <iostream>
#include <boost/asio.hpp>
#include "protocol.hpp"
#include "server.hpp"
#include "client.hpp"
int main()
int main(int argc, char* argv[])
{
using namespace commons::protocol;
auto draw_msg = draw_rectangle{};
try
{
boost::asio::io_context io_context;
if(argc == 1)
{
std::cout << "Running client\n";
client s(io_context, boost::asio::ip::make_address("0.0.0.0"), 9000, 0);
s.init();
io_context.run();
}
for(int i = 0; i < 3; ++i)
{
std::cout << "Size of " << i << " is " << get_size(static_cast<Type>(i)) << "\n";
}
if(argc == 2)
{
std::cout << "Running server\n";
server s(io_context, 9000);
io_context.run();
}
auto rectangle = std::make_unique<draw_pixel>();
void* void_ptr = reinterpret_cast<void*>(rectangle.get());
}
catch (std::exception& e)
{
std::cerr << "Exception: " << e.what() << "\n";
}
generic_message_base* rectangle_ptr = reinterpret_cast<generic_message_base*>(void_ptr);
return 0;
std::cout << "Type: " << static_cast<int>(rectangle_ptr->get_type()) << "\n";
std::cout << "Size: " << static_cast<int>(rectangle_ptr->get_size()) << "\n";
auto* final_msg = get_object(rectangle_ptr->get_type(), rectangle_ptr);
return 0;
// using namespace commons::protocol;
// auto draw_msg = draw_rectangle{};
//
// for(int i = 0; i < 3; ++i)
// {
// std::cout << "Size of " << i << " is " << get_size(static_cast<Type>(i)) << "\n";
// }
//
// auto rectangle = std::make_unique<draw_pixel>();
// void* void_ptr = reinterpret_cast<void*>(rectangle.get());
//
// generic_message_base* rectangle_ptr = reinterpret_cast<generic_message_base*>(void_ptr);
//
// std::cout << "Type: " << static_cast<int>(rectangle_ptr->get_type()) << "\n";
// std::cout << "Size: " << static_cast<int>(rectangle_ptr->get_size()) << "\n";
//
// auto* final_msg = get_object(rectangle_ptr->get_type(), rectangle_ptr);
//
// return 0;
}