diff --git a/examples/BroadcastingEchoServer.cpp b/examples/BroadcastingEchoServer.cpp index c5890e8..6cd700e 100644 --- a/examples/BroadcastingEchoServer.cpp +++ b/examples/BroadcastingEchoServer.cpp @@ -35,10 +35,10 @@ int main() { .drain = [](auto */*ws*/) { /* Check getBufferedAmount here */ }, - .ping = [](auto */*ws*/) { + .ping = [](auto */*ws*/, std::string_view) { }, - .pong = [](auto */*ws*/) { + .pong = [](auto */*ws*/, std::string_view) { }, .close = [](auto */*ws*/, int /*code*/, std::string_view /*message*/) { diff --git a/examples/EchoServer.cpp b/examples/EchoServer.cpp index f7760f1..e96c0f6 100644 --- a/examples/EchoServer.cpp +++ b/examples/EchoServer.cpp @@ -37,10 +37,10 @@ int main() { .drain = [](auto */*ws*/) { /* Check ws->getBufferedAmount() here */ }, - .ping = [](auto */*ws*/) { + .ping = [](auto */*ws*/, std::string_view) { /* Not implemented yet */ }, - .pong = [](auto */*ws*/) { + .pong = [](auto */*ws*/, std::string_view) { /* Not implemented yet */ }, .close = [](auto */*ws*/, int /*code*/, std::string_view /*message*/) { diff --git a/examples/EchoServerThreaded.cpp b/examples/EchoServerThreaded.cpp index 8d9b90a..d0608bb 100644 --- a/examples/EchoServerThreaded.cpp +++ b/examples/EchoServerThreaded.cpp @@ -32,10 +32,10 @@ int main() { .drain = [](auto */*ws*/) { /* Check getBufferedAmount here */ }, - .ping = [](auto */*ws*/) { + .ping = [](auto */*ws*/, std::string_view) { }, - .pong = [](auto */*ws*/) { + .pong = [](auto */*ws*/, std::string_view) { }, .close = [](auto */*ws*/, int /*code*/, std::string_view /*message*/) { diff --git a/examples/UpgradeAsync.cpp b/examples/UpgradeAsync.cpp index 83bf8dc..c2d7c1c 100644 --- a/examples/UpgradeAsync.cpp +++ b/examples/UpgradeAsync.cpp @@ -106,10 +106,10 @@ int main() { .drain = [](auto */*ws*/) { /* Check ws->getBufferedAmount() here */ }, - .ping = [](auto */*ws*/) { + .ping = [](auto */*ws*/, std::string_view) { /* You don't need to handle this one, we automatically respond to pings as per standard */ }, - .pong = [](auto */*ws*/) { + .pong = [](auto */*ws*/, std::string_view) { /* You don't need to handle this one either */ }, .close = [](auto */*ws*/, int /*code*/, std::string_view /*message*/) { diff --git a/examples/UpgradeSync.cpp b/examples/UpgradeSync.cpp index a9f8e44..1928d7a 100644 --- a/examples/UpgradeSync.cpp +++ b/examples/UpgradeSync.cpp @@ -59,10 +59,10 @@ int main() { .drain = [](auto */*ws*/) { /* Check ws->getBufferedAmount() here */ }, - .ping = [](auto */*ws*/) { + .ping = [](auto */*ws*/, std::string_view) { /* You don't need to handle this one, we automatically respond to pings as per standard */ }, - .pong = [](auto */*ws*/) { + .pong = [](auto */*ws*/, std::string_view) { /* You don't need to handle this one either */ }, .close = [](auto */*ws*/, int /*code*/, std::string_view /*message*/) { diff --git a/src/App.h b/src/App.h index 4120699..779d195 100644 --- a/src/App.h +++ b/src/App.h @@ -155,8 +155,8 @@ public: MoveOnlyFunction *)> open = nullptr; MoveOnlyFunction *, std::string_view, OpCode)> message = nullptr; MoveOnlyFunction *)> drain = nullptr; - MoveOnlyFunction *)> ping = nullptr; - MoveOnlyFunction *)> pong = nullptr; + MoveOnlyFunction *, std::string_view)> ping = nullptr; + MoveOnlyFunction *, std::string_view)> pong = nullptr; MoveOnlyFunction *, int, std::string_view)> close = nullptr; }; diff --git a/src/WebSocketContext.h b/src/WebSocketContext.h index 3a24044..84625a4 100644 --- a/src/WebSocketContext.h +++ b/src/WebSocketContext.h @@ -171,14 +171,14 @@ private: if (opCode == PING) { webSocket->send(std::string_view(data, length), (OpCode) OpCode::PONG); if (webSocketContextData->pingHandler) { - webSocketContextData->pingHandler(webSocket); + webSocketContextData->pingHandler(webSocket, {data, length}); if (us_socket_is_closed(SSL, (us_socket_t *) s) || webSocketData->isShuttingDown) { return true; } } } else if (opCode == PONG) { if (webSocketContextData->pongHandler) { - webSocketContextData->pongHandler(webSocket); + webSocketContextData->pongHandler(webSocket, {data, length}); if (us_socket_is_closed(SSL, (us_socket_t *) s) || webSocketData->isShuttingDown) { return true; } @@ -200,14 +200,14 @@ private: if (opCode == PING) { webSocket->send(std::string_view(controlBuffer, webSocketData->controlTipLength), (OpCode) OpCode::PONG); if (webSocketContextData->pingHandler) { - webSocketContextData->pingHandler(webSocket); + webSocketContextData->pingHandler(webSocket, std::string_view(controlBuffer, webSocketData->controlTipLength)); if (us_socket_is_closed(SSL, (us_socket_t *) s) || webSocketData->isShuttingDown) { return true; } } } else if (opCode == PONG) { if (webSocketContextData->pongHandler) { - webSocketContextData->pongHandler(webSocket); + webSocketContextData->pongHandler(webSocket, std::string_view(controlBuffer, webSocketData->controlTipLength)); if (us_socket_is_closed(SSL, (us_socket_t *) s) || webSocketData->isShuttingDown) { return true; } diff --git a/src/WebSocketContextData.h b/src/WebSocketContextData.h index 1b3cf88..269bf70 100644 --- a/src/WebSocketContextData.h +++ b/src/WebSocketContextData.h @@ -52,8 +52,8 @@ public: MoveOnlyFunction *)> drainHandler = nullptr; MoveOnlyFunction *, int, std::string_view)> closeHandler = nullptr; /* Todo: these should take message also; breaking change for v0.18 */ - MoveOnlyFunction *)> pingHandler = nullptr; - MoveOnlyFunction *)> pongHandler = nullptr; + MoveOnlyFunction *, std::string_view)> pingHandler = nullptr; + MoveOnlyFunction *, std::string_view)> pongHandler = nullptr; /* Settings for this context */ size_t maxPayloadLength = 0;