This commit is contained in:
azw 2023-05-07 01:17:03 +00:00
parent 48295756bf
commit 9394d487c0
2 changed files with 12 additions and 2 deletions

View File

@ -16,6 +16,7 @@
#include "master.h"
#include "app.h"
#include "iomgr.h"
const int PACK_MAX = 1024 * 64;
@ -29,7 +30,11 @@ void Master::Init(int instance_id, const std::string& remote_ip, int remote_port
last_pong_tick = a8::XGetTickCount();
recv_buff_ = (char*) malloc(PACK_MAX * 2);
#ifdef USE_ASIO
tcp_client_ = std::make_shared<a8::AsioTcpClient>(remote_ip, remote_port);
auto io_context = IoMgr::Instance()->GetIoContext(IC_Master);
if (!io_context) {
abort();
}
tcp_client_ = std::make_shared<a8::AsioTcpClient>(*io_context, remote_ip, remote_port);
#else
tcp_client_ = std::make_shared<a8::TcpClient>(remote_ip, remote_port);
#endif

View File

@ -17,6 +17,7 @@
#include "upstream.h"
#include "app.h"
#include "iomgr.h"
const int PACK_MAX = 1024 * 64 * 2;
@ -33,7 +34,11 @@ void UpStream::Init(int instance_id, const std::string& remote_ip, int remote_po
last_pong_tick = a8::XGetTickCount();
recv_buff_ = (char*) malloc(PACK_MAX * 2);
#ifdef USE_ASIO
tcp_client_ = std::make_shared<a8::AsioTcpClient>(remote_ip, remote_port);
auto io_context = IoMgr::Instance()->GetIoContext(IC_Master);
if (!io_context) {
abort();
}
tcp_client_ = std::make_shared<a8::AsioTcpClient>(*io_context, remote_ip, remote_port);
#else
tcp_client_ = std::make_shared<a8::TcpClient>(remote_ip, remote_port);
#endif