From 43a1f307a0b6cd6704b3f88bcc62e8e38457e312 Mon Sep 17 00:00:00 2001 From: Alex Hultman Date: Sun, 6 Nov 2022 05:51:51 +0100 Subject: [PATCH] Add subscription event (placeholder) --- src/App.h | 2 ++ src/WebSocketContextData.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/App.h b/src/App.h index 6a14529..b448a72 100644 --- a/src/App.h +++ b/src/App.h @@ -241,6 +241,7 @@ public: MoveOnlyFunction *)> drain = nullptr; MoveOnlyFunction *, std::string_view)> ping = nullptr; MoveOnlyFunction *, std::string_view)> pong = nullptr; + MoveOnlyFunction *, std::string_view, int, int)> subscription = nullptr; MoveOnlyFunction *, int, std::string_view)> close = nullptr; }; @@ -347,6 +348,7 @@ public: webSocketContext->getExt()->openHandler = std::move(behavior.open); webSocketContext->getExt()->messageHandler = std::move(behavior.message); webSocketContext->getExt()->drainHandler = std::move(behavior.drain); + webSocketContext->getExt()->subscriptionHandler = std::move(behavior.subscription); webSocketContext->getExt()->closeHandler = std::move([closeHandler = std::move(behavior.close)](WebSocket *ws, int code, std::string_view message) mutable { if (closeHandler) { closeHandler(ws, code, message); diff --git a/src/WebSocketContextData.h b/src/WebSocketContextData.h index 49049db..8c41894 100644 --- a/src/WebSocketContextData.h +++ b/src/WebSocketContextData.h @@ -60,8 +60,8 @@ public: MoveOnlyFunction *)> openHandler = nullptr; MoveOnlyFunction *, std::string_view, OpCode)> messageHandler = nullptr; MoveOnlyFunction *)> drainHandler = nullptr; + MoveOnlyFunction *, std::string_view, int, int)> subscriptionHandler = nullptr; MoveOnlyFunction *, int, std::string_view)> closeHandler = nullptr; - /* Todo: these should take message also; breaking change for v0.18 */ MoveOnlyFunction *, std::string_view)> pingHandler = nullptr; MoveOnlyFunction *, std::string_view)> pongHandler = nullptr;