From 5d69655f4357572132021950e8ac9b64253ec6e1 Mon Sep 17 00:00:00 2001 From: azw Date: Thu, 4 May 2023 15:51:44 +0000 Subject: [PATCH] 1 --- server/wsproxy/upstream.cc | 6 ++++++ server/wsproxy/upstream.h | 11 +++++++++++ server/wsproxy/upstreammgr.cc | 6 +++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/server/wsproxy/upstream.cc b/server/wsproxy/upstream.cc index efae6a5..d56036b 100644 --- a/server/wsproxy/upstream.cc +++ b/server/wsproxy/upstream.cc @@ -16,6 +16,12 @@ const int PACK_MAX = 1024 * 64 * 2; +#ifdef USE_ASIO +UpStream::UpStream(asio::io_context& io_context):socket_(io_context) +{ +} +#endif + void UpStream::Init(int instance_id, const std::string& remote_ip, int remote_port) { if (remote_ip.empty()) { diff --git a/server/wsproxy/upstream.h b/server/wsproxy/upstream.h index e0b37c3..b03a3d9 100644 --- a/server/wsproxy/upstream.h +++ b/server/wsproxy/upstream.h @@ -2,6 +2,10 @@ #include +#ifdef USE_ASIO +#include +#endif + namespace a8 { class TcpClient; @@ -26,6 +30,10 @@ class UpStream a8::tick_t last_pong_tick = 0; public: +#ifdef USE_ASIO + UpStream(asio::io_context& io_context); +#endif + void Init(int instance_id, const std::string& remote_ip, int remote_port); void UnInit(); @@ -67,6 +75,9 @@ class UpStream char *recv_buff_ = nullptr; unsigned int recv_bufflen_ = 0; std::shared_ptr tcp_client_; +#ifdef USE_ASIO + asio::ip::tcp::socket socket_; +#endif f8::TimerWp timer_wp_; f8::Attacher attacher_; diff --git a/server/wsproxy/upstreammgr.cc b/server/wsproxy/upstreammgr.cc index a1634b1..2f05427 100644 --- a/server/wsproxy/upstreammgr.cc +++ b/server/wsproxy/upstreammgr.cc @@ -55,8 +55,12 @@ std::weak_ptr UpStreamMgr::RecreateUpStream(const std::string& host, i int instance_id = curr_id_; std::string remote_ip = host; int remote_port = port; - +#ifdef USE_ASIO + asio::io_context io_context; + std::shared_ptr conn = std::make_shared(io_context); +#else std::shared_ptr conn = std::make_shared(); +#endif conn->Init(instance_id, remote_ip, remote_port); id_hash_[conn->instance_id] = conn; key_hash_[key] = conn;