Skip to content
This repository was archived by the owner on Jan 21, 2025. It is now read-only.

Commit f0eb0ac

Browse files
committed
Added WS_PING event
1 parent 0eba19d commit f0eb0ac

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

src/AsyncWebSocket.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,10 +568,11 @@ void AsyncWebSocketClient::_onData(void* pbuf, size_t plen) {
568568
_queueControl(WS_DISCONNECT, data, datalen);
569569
}
570570
} else if (_pinfo.opcode == WS_PING) {
571+
_server->_handleEvent(this, WS_EVT_PING, NULL, NULL, 0);
571572
_queueControl(WS_PONG, data, datalen);
572573
} else if (_pinfo.opcode == WS_PONG) {
573574
if (datalen != AWSC_PING_PAYLOAD_LEN || memcmp(AWSC_PING_PAYLOAD, data, AWSC_PING_PAYLOAD_LEN) != 0)
574-
_server->_handleEvent(this, WS_EVT_PONG, NULL, data, datalen);
575+
_server->_handleEvent(this, WS_EVT_PONG, NULL, NULL, 0);
575576
} else if (_pinfo.opcode < WS_DISCONNECT) { // continuation or text/binary frame
576577
_server->_handleEvent(this, WS_EVT_DATA, (void*)&_pinfo, data, datalen);
577578
if (_pinfo.final)

src/AsyncWebSocket.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ typedef enum { WS_MSG_SENDING,
104104
WS_MSG_ERROR } AwsMessageStatus;
105105
typedef enum { WS_EVT_CONNECT,
106106
WS_EVT_DISCONNECT,
107+
WS_EVT_PING,
107108
WS_EVT_PONG,
108109
WS_EVT_ERROR,
109110
WS_EVT_DATA } AwsEventType;

0 commit comments

Comments
 (0)