From 6d98a3f4efbb8cc40e56563c46fcbd750bc9b8f9 Mon Sep 17 00:00:00 2001 From: Mike Seese Date: Tue, 7 May 2024 11:17:39 -0700 Subject: [PATCH 1/2] use custom namespace for asio to prevent UE collision --- .../Private/internal/sio_client_impl.cpp | 36 +++++++++---------- .../Private/internal/sio_client_impl.h | 14 ++++---- Source/SocketIOLib/Private/sio_client.cpp | 4 +-- Source/SocketIOLib/Private/sio_socket.cpp | 6 ++-- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/Source/SocketIOLib/Private/internal/sio_client_impl.cpp b/Source/SocketIOLib/Private/internal/sio_client_impl.cpp index e73efe9..ad4a60b 100644 --- a/Source/SocketIOLib/Private/internal/sio_client_impl.cpp +++ b/Source/SocketIOLib/Private/internal/sio_client_impl.cpp @@ -235,7 +235,7 @@ namespace sio } template - asio::io_service& client_impl::get_io_service() + asio_sockio::io_service& client_impl::get_io_service() { return m_client.get_io_service(); } @@ -361,11 +361,11 @@ namespace sio } template - void client_impl::ping(const asio::error_code& ec) + void client_impl::ping(const asio_sockio::error_code& ec) { if (ec || m_con.expired()) { - if (ec != asio::error::operation_aborted) + if (ec != asio_sockio::error::operation_aborted) //LOG("ping exit,con is expired?" << m_con.expired() << ",ec:" << ec.message() << endl); return; } @@ -377,7 +377,7 @@ namespace sio }); if (!m_ping_timeout_timer) { - m_ping_timeout_timer.reset(new asio::steady_timer(m_client.get_io_service())); + m_ping_timeout_timer.reset(new asio_sockio::steady_timer(m_client.get_io_service())); std::error_code timeout_ec; m_ping_timeout_timer->expires_from_now(milliseconds(m_ping_timeout), timeout_ec); m_ping_timeout_timer->async_wait(std::bind(&client_impl::timeout_pong, this, std::placeholders::_1)); @@ -385,7 +385,7 @@ namespace sio } template - void client_impl::timeout_pong(const asio::error_code& ec) + void client_impl::timeout_pong(const asio_sockio::error_code& ec) { if (ec) { @@ -396,7 +396,7 @@ namespace sio } template - void client_impl::timeout_reconnect(asio::error_code const& ec) + void client_impl::timeout_reconnect(asio_sockio::error_code const& ec) { if (ec) { @@ -467,8 +467,8 @@ namespace sio LOG("Reconnect for attempt:" << m_reconn_made << endl); unsigned delay = this->next_delay(); if (m_reconnect_listener) m_reconnect_listener(m_reconn_made, delay); - m_reconn_timer.reset(new asio::steady_timer(m_client.get_io_service())); - asio::error_code ec; + m_reconn_timer.reset(new asio_sockio::steady_timer(m_client.get_io_service())); + asio_sockio::error_code ec; m_reconn_timer->expires_from_now(milliseconds(delay), ec); m_reconn_timer->async_wait(std::bind(&client_impl::timeout_reconnect, this, std::placeholders::_1)); } @@ -533,8 +533,8 @@ namespace sio LOG("Reconnect for attempt:" << m_reconn_made << endl); unsigned delay = this->next_delay(); if (m_reconnect_listener) m_reconnect_listener(m_reconn_made, delay); - m_reconn_timer.reset(new asio::steady_timer(m_client.get_io_service())); - asio::error_code ec2; + m_reconn_timer.reset(new asio_sockio::steady_timer(m_client.get_io_service())); + asio_sockio::error_code ec2; m_reconn_timer->expires_from_now(milliseconds(delay), ec2); m_reconn_timer->async_wait(std::bind(&client_impl::timeout_reconnect, this, std::placeholders::_1)); return; @@ -552,7 +552,7 @@ namespace sio void client_impl::on_message(connection_hdl, message_ptr msg) { if (m_ping_timeout_timer) { - asio::error_code ec; + asio_sockio::error_code ec; m_ping_timeout_timer->expires_from_now(milliseconds(m_ping_timeout), ec); m_ping_timeout_timer->async_wait(std::bind(&client_impl::timeout_pong, this, std::placeholders::_1)); } @@ -654,7 +654,7 @@ namespace sio void client_impl::clear_timers() { LOG("clear timers" << endl); - asio::error_code ec; + asio_sockio::error_code ec; if (m_ping_timeout_timer) { m_ping_timeout_timer->cancel(ec); @@ -676,14 +676,14 @@ namespace sio } #if SIO_TLS - typedef websocketpp::lib::shared_ptr context_ptr; + typedef websocketpp::lib::shared_ptr context_ptr; static context_ptr on_tls_init(int verify_mode, connection_hdl conn) { - context_ptr ctx = context_ptr(new asio::ssl::context(asio::ssl::context::tlsv12)); - asio::error_code ec; - ctx->set_options(asio::ssl::context::default_workarounds | - asio::ssl::context::no_sslv2 | - asio::ssl::context::single_dh_use, ec); + context_ptr ctx = context_ptr(new asio_sockio::ssl::context(asio_sockio::ssl::context::tlsv12)); + asio_sockio::error_code ec; + ctx->set_options(asio_sockio::ssl::context::default_workarounds | + asio_sockio::ssl::context::no_sslv2 | + asio_sockio::ssl::context::single_dh_use, ec); if (ec) { cerr << "Init tls failed,reason:" << ec.message() << endl; diff --git a/Source/SocketIOLib/Private/internal/sio_client_impl.h b/Source/SocketIOLib/Private/internal/sio_client_impl.h index 6e2d3f8..19c050f 100644 --- a/Source/SocketIOLib/Private/internal/sio_client_impl.h +++ b/Source/SocketIOLib/Private/internal/sio_client_impl.h @@ -127,7 +127,7 @@ // used by sio::socket virtual void send(packet& p) {}; virtual void remove_socket(std::string const& nsp) {}; - virtual asio::io_service& get_io_service() = 0; + virtual asio_sockio::io_service& get_io_service() = 0; virtual void on_socket_closed(std::string const& nsp) {}; virtual void on_socket_opened(std::string const& nsp) {}; @@ -221,7 +221,7 @@ void remove_socket(std::string const& nsp); - asio::io_service& get_io_service(); + asio_sockio::io_service& get_io_service(); void on_socket_closed(std::string const& nsp); @@ -236,11 +236,11 @@ void send_impl(std::shared_ptr const& payload_ptr, frame::opcode::value opcode); - void ping(const asio::error_code& ec); + void ping(const asio_sockio::error_code& ec); - void timeout_pong(const asio::error_code& ec); + void timeout_pong(const asio_sockio::error_code& ec); - void timeout_reconnect(asio::error_code const& ec); + void timeout_reconnect(asio_sockio::error_code const& ec); unsigned next_delay() const; @@ -290,9 +290,9 @@ packet_manager m_packet_mgr; - std::unique_ptr m_ping_timeout_timer; + std::unique_ptr m_ping_timeout_timer; - std::unique_ptr m_reconn_timer; + std::unique_ptr m_reconn_timer; con_state m_con_state; diff --git a/Source/SocketIOLib/Private/sio_client.cpp b/Source/SocketIOLib/Private/sio_client.cpp index 1e7b44c..5df79cb 100644 --- a/Source/SocketIOLib/Private/sio_client.cpp +++ b/Source/SocketIOLib/Private/sio_client.cpp @@ -45,12 +45,12 @@ namespace sio if (bShouldVerifyTLSCertificate) { - m_impl->set_verify_mode(asio::ssl::verify_peer); + m_impl->set_verify_mode(asio_sockio::ssl::verify_peer); // TODO: add verify CA chain file } else { - m_impl->set_verify_mode(asio::ssl::verify_none); + m_impl->set_verify_mode(asio_sockio::ssl::verify_none); } m_impl->template_init(); // reinitialize based on the new mode diff --git a/Source/SocketIOLib/Private/sio_socket.cpp b/Source/SocketIOLib/Private/sio_socket.cpp index cb00c46..42d4f7c 100644 --- a/Source/SocketIOLib/Private/sio_socket.cpp +++ b/Source/SocketIOLib/Private/sio_socket.cpp @@ -208,7 +208,7 @@ namespace sio error_listener m_error_listener; - std::unique_ptr m_connection_timer; + std::unique_ptr m_connection_timer; std::queue m_packet_queue; @@ -300,7 +300,7 @@ namespace sio NULL_GUARD(m_client); packet p(packet::type_connect, m_nsp, m_auth); m_client->send(p); - m_connection_timer.reset(new asio::system_timer(m_client->get_io_service())); + m_connection_timer.reset(new asio_sockio::system_timer(m_client->get_io_service())); lib::error_code ec; m_connection_timer->expires_from_now(std::chrono::milliseconds(20000), ec); m_connection_timer->async_wait(std::bind(&socket::impl::timeout_connection,this, std::placeholders::_1)); @@ -316,7 +316,7 @@ namespace sio if(!m_connection_timer) { - m_connection_timer.reset(new asio::system_timer(m_client->get_io_service())); + m_connection_timer.reset(new asio_sockio::system_timer(m_client->get_io_service())); } lib::error_code ec; m_connection_timer->expires_from_now(std::chrono::milliseconds(3000), ec); From 62268574a6f051636408079aed8d8cabbe100a2d Mon Sep 17 00:00:00 2001 From: Mike Seese Date: Tue, 7 May 2024 14:31:06 -0700 Subject: [PATCH 2/2] update ThirdParty submodules to fix namespace collision --- Source/ThirdParty/asio | 2 +- Source/ThirdParty/websocketpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/ThirdParty/asio b/Source/ThirdParty/asio index a59ab45..d7b7757 160000 --- a/Source/ThirdParty/asio +++ b/Source/ThirdParty/asio @@ -1 +1 @@ -Subproject commit a59ab452265e3f9fdb77dd52aa1064f14eca0989 +Subproject commit d7b77578a23722b23725806df54b898e290aabcb diff --git a/Source/ThirdParty/websocketpp b/Source/ThirdParty/websocketpp index 72e2760..a13cd8c 160000 --- a/Source/ThirdParty/websocketpp +++ b/Source/ThirdParty/websocketpp @@ -1 +1 @@ -Subproject commit 72e2760a4cceef2d270450746ce90efce9374eb8 +Subproject commit a13cd8cd9a9d6841c0453b6e8afefedd8521bb16