-
Notifications
You must be signed in to change notification settings - Fork 175
Open
Labels
Status: In ProgressType: Feature RequestFeature Request for esp-protocolsFeature Request for esp-protocols
Description
Is your feature request related to a problem?
Currently when esp_websocket_client_recv() processes a PONG response it will be dispatched to the client event handler as a WEBSOCKET_EVENT_DATA with NULL data and zero length.
Describe the solution you'd like.
I would like to propose 3 options:
- Filter it out all together:
/**
* esp_websocket_client_recv()
*/
if (client->last_opcode != WS_TRANSPORT_OPCODES_PONG) {
esp_websocket_client_dispatch_event(client, WEBSOCKET_EVENT_DATA, client->rx_buffer, rlen);
} else {
ESP_LOGD(TAG, "Skipping event dispatch for PONG frame.");
}
- Add a specific WEBSOCKET_EVENT_PONG to esp_websocket_event_id_t to allow it to be properly identified and handled by the client event function:
if (client->last_opcode != WS_TRANSPORT_OPCODES_PONG) {
esp_websocket_client_dispatch_event(client, WEBSOCKET_EVENT_DATA, client->rx_buffer, rlen);
} else {
esp_websocket_client_dispatch_event(client, WEBSOCKET_EVENT_PONG, client->rx_buffer, rlen);
}
- Add a define/config option for user choice.
Describe alternatives you've considered.
See above
Additional context.
I chose option 1 as I have no need to process PONG responses at an app level. But someone might find value in the distinct ability to process PONGs at an application level...
Just to note, the AsyncWebSocket (in EAPAsyncWebServer) bubbles up those events:
typedef enum {
WS_EVT_CONNECT,
WS_EVT_DISCONNECT,
WS_EVT_PING,
WS_EVT_PONG,
WS_EVT_ERROR,
WS_EVT_DATA
} AwsEventType;
Metadata
Metadata
Assignees
Labels
Status: In ProgressType: Feature RequestFeature Request for esp-protocolsFeature Request for esp-protocols