Skip to content
Open
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
8 changes: 8 additions & 0 deletions src/internal/sio_client_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ namespace sio
m_ping_timeout_timer->expires_from_now(milliseconds(m_ping_timeout), timeout_ec);
m_ping_timeout_timer->async_wait(lib::bind(&client_impl::timeout_pong, this,lib::placeholders::_1));
}
if(m_ping_sent_listener)
{
m_ping_sent_listener();
}
}

void client_impl::timeout_pong(const boost::system::error_code &ec)
Expand Down Expand Up @@ -505,6 +509,10 @@ namespace sio
m_ping_timeout_timer->cancel();
m_ping_timeout_timer.reset();
}
if(m_pong_received_listener)
{
m_pong_received_listener();
}
}

void client_impl::on_decode(packet const& p)
Expand Down
10 changes: 10 additions & 0 deletions src/internal/sio_client_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ namespace sio
void set_##__FIELD__(__TYPE__ const& l) \
{ m_##__FIELD__ = l;}

SYNTHESIS_SETTER(client::con_listener,ping_sent_listener)

SYNTHESIS_SETTER(client::con_listener,pong_received_listener)

SYNTHESIS_SETTER(client::con_listener,open_listener)

SYNTHESIS_SETTER(client::con_listener,fail_listener)
Expand All @@ -83,6 +87,9 @@ namespace sio

void clear_con_listeners()
{
m_ping_sent_listener = nullptr;
m_pong_received_listener = nullptr;

m_open_listener = nullptr;
m_close_listener = nullptr;
m_fail_listener = nullptr;
Expand Down Expand Up @@ -200,6 +207,9 @@ namespace sio

con_state m_con_state;

client::con_listener m_ping_sent_listener;
client::con_listener m_pong_received_listener;

client::con_listener m_open_listener;
client::con_listener m_fail_listener;
client::con_listener m_reconnecting_listener;
Expand Down
10 changes: 10 additions & 0 deletions src/sio_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ namespace sio
delete m_impl;
}

void client::set_ping_sent_listener(con_listener const& l)
{
m_impl->set_ping_sent_listener(l);
}

void client::set_pong_received_listener(con_listener const& l)
{
m_impl->set_pong_received_listener(l);
}

void client::set_open_listener(con_listener const& l)
{
m_impl->set_open_listener(l);
Expand Down
4 changes: 4 additions & 0 deletions src/sio_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ namespace sio
~client();

//set listeners and event bindings.
void set_ping_sent_listener(con_listener const& l);

void set_pong_received_listener(con_listener const& l);

void set_open_listener(con_listener const& l);

void set_fail_listener(con_listener const& l);
Expand Down