mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
Merge remote-tracking branch 'tmj/master' into sim
This commit is contained in:
@@ -134,7 +134,7 @@ void network::tcp::connection::send_message(const message &msg)
|
||||
// -----------------
|
||||
|
||||
network::tcp::server::server(std::shared_ptr<std::istream> buf, asio::io_context &io_ctx, const std::string &host, uint32_t port)
|
||||
: network::server(buf), m_acceptor(io_ctx)
|
||||
: network::server(buf), m_acceptor(io_ctx), m_io_ctx(io_ctx)
|
||||
{
|
||||
auto endpoint = asio::ip::tcp::endpoint(asio::ip::address::from_string(host), port);
|
||||
m_acceptor.open(endpoint.protocol());
|
||||
@@ -147,11 +147,11 @@ network::tcp::server::server(std::shared_ptr<std::istream> buf, asio::io_context
|
||||
}
|
||||
|
||||
void network::tcp::server::accept_conn()
|
||||
{/*
|
||||
std::shared_ptr<connection> conn = std::make_shared<connection>(m_acceptor.get_executor().context());
|
||||
conn->set_handler(std::bind(&server::handle_message, this, conn, std::placeholders::_1));
|
||||
{
|
||||
std::shared_ptr<connection> conn = std::make_shared<connection>(m_io_ctx);
|
||||
conn->set_handler(std::bind(&server::handle_message, this, conn, std::placeholders::_1));
|
||||
|
||||
m_acceptor.async_accept(conn->m_socket, std::bind(&server::handle_accept, this, conn, std::placeholders::_1));*/
|
||||
m_acceptor.async_accept(conn->m_socket, std::bind(&server::handle_accept, this, conn, std::placeholders::_1));
|
||||
}
|
||||
|
||||
void network::tcp::server::handle_accept(std::shared_ptr<connection> conn, const asio::error_code &err)
|
||||
@@ -210,7 +210,7 @@ void network::tcp::client::handle_accept(const asio::error_code &err)
|
||||
}
|
||||
|
||||
network::tcp::asio_manager::asio_manager() {
|
||||
backend_list.emplace("tcp", this);
|
||||
backend_list().emplace("tcp", this);
|
||||
}
|
||||
|
||||
std::shared_ptr<network::server> network::tcp::asio_manager::create_server(std::shared_ptr<std::fstream> backbuffer, const std::string &conf) {
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
#include "network/network.h"
|
||||
#ifdef DBG_NEW
|
||||
#undef new
|
||||
#endif
|
||||
|
||||
#include <asio.hpp>
|
||||
|
||||
#include "network/network.h"
|
||||
|
||||
namespace network::tcp
|
||||
{
|
||||
const uint32_t NETWORK_MAGIC = 0x37305545;
|
||||
@@ -13,7 +17,7 @@ namespace network::tcp
|
||||
friend class client;
|
||||
|
||||
public:
|
||||
connection(asio::io_context &io_ctx, bool client = false, size_t counter = 0);
|
||||
connection(asio::io_context &io_ctx, bool client = false, size_t counter = 0);
|
||||
~connection();
|
||||
|
||||
virtual void connected() override;
|
||||
@@ -41,6 +45,7 @@ namespace network::tcp
|
||||
void handle_accept(std::shared_ptr<connection> conn, const asio::error_code &err);
|
||||
|
||||
asio::ip::tcp::acceptor m_acceptor;
|
||||
asio::io_context &m_io_ctx;
|
||||
|
||||
public:
|
||||
server(std::shared_ptr<std::istream> buf, asio::io_context &io_ctx, const std::string &host, uint32_t port);
|
||||
|
||||
Reference in New Issue
Block a user