Skip to content

Commit

Permalink
Merge pull request #418 from RedwoodMMO/fix/namespace-collision
Browse files Browse the repository at this point in the history
Use custom namespace for asio to prevent UE collision
  • Loading branch information
getnamo authored May 7, 2024
2 parents 72d3e48 + 6226857 commit 879c927
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 32 deletions.
36 changes: 18 additions & 18 deletions Source/SocketIOLib/Private/internal/sio_client_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ namespace sio
}

template<typename client_type>
asio::io_service& client_impl<client_type>::get_io_service()
asio_sockio::io_service& client_impl<client_type>::get_io_service()
{
return m_client.get_io_service();
}
Expand Down Expand Up @@ -361,11 +361,11 @@ namespace sio
}

template<typename client_type>
void client_impl<client_type>::ping(const asio::error_code& ec)
void client_impl<client_type>::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;
}
Expand All @@ -377,15 +377,15 @@ 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<client_type>::timeout_pong, this, std::placeholders::_1));
}
}

template<typename client_type>
void client_impl<client_type>::timeout_pong(const asio::error_code& ec)
void client_impl<client_type>::timeout_pong(const asio_sockio::error_code& ec)
{
if (ec)
{
Expand All @@ -396,7 +396,7 @@ namespace sio
}

template<typename client_type>
void client_impl<client_type>::timeout_reconnect(asio::error_code const& ec)
void client_impl<client_type>::timeout_reconnect(asio_sockio::error_code const& ec)
{
if (ec)
{
Expand Down Expand Up @@ -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<client_type>::timeout_reconnect, this, std::placeholders::_1));
}
Expand Down Expand Up @@ -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<client_type>::timeout_reconnect, this, std::placeholders::_1));
return;
Expand All @@ -552,7 +552,7 @@ namespace sio
void client_impl<client_type>::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<client_type>::timeout_pong, this, std::placeholders::_1));
}
Expand Down Expand Up @@ -654,7 +654,7 @@ namespace sio
void client_impl<client_type>::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);
Expand All @@ -676,14 +676,14 @@ namespace sio
}

#if SIO_TLS
typedef websocketpp::lib::shared_ptr<asio::ssl::context> context_ptr;
typedef websocketpp::lib::shared_ptr<asio_sockio::ssl::context> 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;
Expand Down
14 changes: 7 additions & 7 deletions Source/SocketIOLib/Private/internal/sio_client_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {};

Expand Down Expand Up @@ -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);

Expand All @@ -236,11 +236,11 @@

void send_impl(std::shared_ptr<const std::string> 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;

Expand Down Expand Up @@ -290,9 +290,9 @@

packet_manager m_packet_mgr;

std::unique_ptr<asio::steady_timer> m_ping_timeout_timer;
std::unique_ptr<asio_sockio::steady_timer> m_ping_timeout_timer;

std::unique_ptr<asio::steady_timer> m_reconn_timer;
std::unique_ptr<asio_sockio::steady_timer> m_reconn_timer;

con_state m_con_state;

Expand Down
4 changes: 2 additions & 2 deletions Source/SocketIOLib/Private/sio_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions Source/SocketIOLib/Private/sio_socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ namespace sio

error_listener m_error_listener;

std::unique_ptr<asio::system_timer> m_connection_timer;
std::unique_ptr<asio_sockio::system_timer> m_connection_timer;

std::queue<packet> m_packet_queue;

Expand Down Expand Up @@ -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));
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Source/ThirdParty/asio
Submodule asio updated 719 files
2 changes: 1 addition & 1 deletion Source/ThirdParty/websocketpp

0 comments on commit 879c927

Please sign in to comment.