add server/client to namespace commons
This commit is contained in:
@@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
#include "boost/bind.hpp"
|
#include "boost/bind.hpp"
|
||||||
|
|
||||||
|
namespace commons {
|
||||||
|
|
||||||
class client {
|
class client {
|
||||||
public:
|
public:
|
||||||
client(boost::asio::io_service& io_service,
|
client(boost::asio::io_service& io_service,
|
||||||
@@ -26,3 +28,5 @@ class client {
|
|||||||
std::string message_;
|
std::string message_;
|
||||||
unsigned short port_;
|
unsigned short port_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace commons
|
||||||
|
|||||||
@@ -7,7 +7,10 @@
|
|||||||
#include "protocol.hpp"
|
#include "protocol.hpp"
|
||||||
#include "spdlog/spdlog.h"
|
#include "spdlog/spdlog.h"
|
||||||
|
|
||||||
|
namespace commons {
|
||||||
|
|
||||||
using boost::asio::ip::udp;
|
using boost::asio::ip::udp;
|
||||||
|
using namespace protocol;
|
||||||
|
|
||||||
class server {
|
class server {
|
||||||
public:
|
public:
|
||||||
@@ -55,3 +58,5 @@ class server {
|
|||||||
enum { max_length = 1024 };
|
enum { max_length = 1024 };
|
||||||
char data_[max_length];
|
char data_[max_length];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace commons
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
#include "protocol.hpp"
|
#include "protocol.hpp"
|
||||||
#include "spdlog/spdlog.h"
|
#include "spdlog/spdlog.h"
|
||||||
|
|
||||||
|
namespace commons {
|
||||||
|
|
||||||
client::client(boost::asio::io_service& io_service,
|
client::client(boost::asio::io_service& io_service,
|
||||||
const boost::asio::ip::address& multicast_address,
|
const boost::asio::ip::address& multicast_address,
|
||||||
short multicast_port, unsigned short tcp_port)
|
short multicast_port, unsigned short tcp_port)
|
||||||
@@ -54,3 +56,5 @@ void client::handle_timeout(const boost::system::error_code& error) {
|
|||||||
// std::placeholders::_1));
|
// std::placeholders::_1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace commons
|
||||||
|
|||||||
@@ -14,15 +14,16 @@ void init_spdlog() {
|
|||||||
void run_client() {
|
void run_client() {
|
||||||
boost::asio::io_context io_context;
|
boost::asio::io_context io_context;
|
||||||
spdlog::info("Running client...");
|
spdlog::info("Running client...");
|
||||||
client s(io_context, boost::asio::ip::make_address("0.0.0.0"), 9000, 0);
|
commons::client s(io_context, boost::asio::ip::make_address("0.0.0.0"), 9000,
|
||||||
|
0);
|
||||||
s.init();
|
s.init();
|
||||||
io_context.run();
|
io_context.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
void run_server() {
|
void run_server() {
|
||||||
boost::asio::io_context io_context;
|
boost::asio::io_context io_context;
|
||||||
spdlog::info("Running client...");
|
spdlog::info("Running server...");
|
||||||
server s(io_context, 9000);
|
commons::server s(io_context, 9000);
|
||||||
io_context.run();
|
io_context.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
#include "protocol.hpp"
|
#include "protocol.hpp"
|
||||||
|
|
||||||
|
namespace commons::protocol {} // namespace commons::protocol
|
||||||
|
|||||||
Reference in New Issue
Block a user