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