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;