Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/internal/sio_client_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ namespace sio
m_http_headers = headers;

this->reset_states();
m_abort_retries = false;
m_client.get_io_service().dispatch(std::bind(&client_impl::connect_impl,this,uri,m_query_string));
m_network_thread.reset(new thread(std::bind(&client_impl::run_loop,this)));//uri lifecycle?

Expand Down Expand Up @@ -148,13 +149,15 @@ namespace sio
void client_impl::close()
{
m_con_state = con_closing;
m_abort_retries = true;
this->sockets_invoke_void(&sio::socket::close);
m_client.get_io_service().dispatch(std::bind(&client_impl::close_impl, this,close::status::normal,"End by user"));
}

void client_impl::sync_close()
{
m_con_state = con_closing;
m_abort_retries = true;
this->sockets_invoke_void(&sio::socket::close);
m_client.get_io_service().dispatch(std::bind(&client_impl::close_impl, this,close::status::normal,"End by user"));
if(m_network_thread)
Expand Down Expand Up @@ -397,7 +400,7 @@ namespace sio
m_con_state = con_closed;
this->sockets_invoke_void(&sio::socket::on_disconnect);
LOG("Connection failed." << endl);
if(m_reconn_made<m_reconn_attempts)
if(m_reconn_made<m_reconn_attempts && !m_abort_retries)
{
LOG("Reconnect for attempt:"<<m_reconn_made<<endl);
unsigned delay = this->next_delay();
Expand Down Expand Up @@ -461,7 +464,7 @@ namespace sio
else
{
this->sockets_invoke_void(&sio::socket::on_disconnect);
if(m_reconn_made<m_reconn_attempts)
if(m_reconn_made<m_reconn_attempts && !m_abort_retries)
{
LOG("Reconnect for attempt:"<<m_reconn_made<<endl);
unsigned delay = this->next_delay();
Expand Down
5 changes: 4 additions & 1 deletion src/internal/sio_client_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ typedef websocketpp::config::asio_client client_config;
#include <asio/error_code.hpp>
#include <asio/io_service.hpp>

#include <atomic>
#include <memory>
#include <map>
#include <thread>
Expand Down Expand Up @@ -233,7 +234,9 @@ namespace sio
unsigned m_reconn_attempts;

unsigned m_reconn_made;


std::atomic<bool> m_abort_retries { false };

friend class sio::client;
friend class sio::socket;
};
Expand Down