From 591518b2d0749165e6c5a3aca55ee1d1c0454bdc Mon Sep 17 00:00:00 2001 From: Alex Hultman Date: Sat, 29 Feb 2020 00:18:25 +0100 Subject: [PATCH] Ping/pong ahoy --- src/App.h | 2 ++ src/WebSocketContextData.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/App.h b/src/App.h index 7837053..c80679b 100644 --- a/src/App.h +++ b/src/App.h @@ -145,6 +145,8 @@ public: /* Destruct user data after returning from close handler */ ((UserData *) ws->getUserData())->~UserData(); }); + webSocketContext->getExt()->pingHandler = std::move(behavior.ping); + webSocketContext->getExt()->pongHandler = std::move(behavior.pong); /* Copy settings */ webSocketContext->getExt()->maxPayloadLength = behavior.maxPayloadLength; diff --git a/src/WebSocketContextData.h b/src/WebSocketContextData.h index d27b1a6..1f0d1ac 100644 --- a/src/WebSocketContextData.h +++ b/src/WebSocketContextData.h @@ -36,6 +36,9 @@ struct WebSocketContextData { fu2::unique_function *, std::string_view, uWS::OpCode)> messageHandler = nullptr; fu2::unique_function *)> drainHandler = nullptr; fu2::unique_function *, int, std::string_view)> closeHandler = nullptr; + /* Todo: these should take message also; breaking change for v0.18 */ + fu2::unique_function *)> pingHandler = nullptr; + fu2::unique_function *)> pongHandler = nullptr; /* Settings for this context */ size_t maxPayloadLength = 0;