diff --git a/src/cpp/ripple/WSConnection.h b/src/cpp/ripple/WSConnection.h index bf179b2518..291a6b035c 100644 --- a/src/cpp/ripple/WSConnection.h +++ b/src/cpp/ripple/WSConnection.h @@ -142,16 +142,18 @@ public: return jvResult; } - bool onPingTimer() + bool onPingTimer(std::string&) { +#ifdef DISCONNECT_ON_WEBSOCKET_PING_TIMEOUTS if (mPinged) return true; // causes connection to close +#endif mPinged = true; setPingTimer(); return false; // causes ping to be sent } - void onPong() + void onPong(const std::string&) { mPinged = false; } diff --git a/src/cpp/ripple/WSHandler.h b/src/cpp/ripple/WSHandler.h index b2d4acb8c6..b525859b94 100644 --- a/src/cpp/ripple/WSHandler.h +++ b/src/cpp/ripple/WSHandler.h @@ -94,15 +94,14 @@ public: return; ptr = it->second; } - if (ptr->onPingTimer()) + std::string data("ping"); + if (ptr->onPingTimer(data)) { cLog(lsWARNING) << "Connection pings out"; cpClient->close(websocketpp::close::status::PROTOCOL_ERROR, "ping timeout"); } else - { - cpClient->ping("ping"); - } + cpClient->ping(data); } void on_send_empty(connection_ptr cpClient) @@ -126,7 +125,7 @@ public: mMap[cpClient] = boost::make_shared< WSConnection >(this, cpClient); } - void on_pong(connection_ptr cpClient, std::string) + void on_pong(connection_ptr cpClient, std::string data) { wsc_ptr ptr; { @@ -136,7 +135,7 @@ public: return; ptr = it->second; } - ptr->onPong(); + ptr->onPong(data); } void on_close(connection_ptr cpClient)