use spdlog and start using google coding style
This commit is contained in:
71
src/main.cpp
71
src/main.cpp
@@ -1,55 +1,46 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "client.hpp"
|
||||
#include "protocol.hpp"
|
||||
#include "server.hpp"
|
||||
#include "client.hpp"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
void init_spdlog() {
|
||||
spdlog::set_level(spdlog::level::debug); // Set global log level to debug
|
||||
// spdlog::set_pattern("[%H:%M:%S %z] [%n] [%^---%L---%$] [thread %t] %v");
|
||||
spdlog::debug("Setting Loglevel to debug...");
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
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();
|
||||
void run_client() {
|
||||
boost::asio::io_context io_context;
|
||||
spdlog::info("Running client...");
|
||||
client s(io_context, boost::asio::ip::make_address("0.0.0.0"), 9000, 0);
|
||||
s.init();
|
||||
io_context.run();
|
||||
}
|
||||
|
||||
void run_server() {
|
||||
boost::asio::io_context io_context;
|
||||
spdlog::info("Running client...");
|
||||
server s(io_context, 9000);
|
||||
io_context.run();
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
init_spdlog();
|
||||
|
||||
try {
|
||||
if (argc == 1) {
|
||||
run_client();
|
||||
}
|
||||
|
||||
if(argc == 2)
|
||||
{
|
||||
std::cout << "Running server\n";
|
||||
server s(io_context, 9000);
|
||||
io_context.run();
|
||||
if (argc == 2) {
|
||||
run_server();
|
||||
}
|
||||
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
} catch (std::exception &e) {
|
||||
std::cerr << "Exception: " << e.what() << "\n";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user