mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-07-29 10:17:30 +02:00
Merge pull request #22 from 0xFEEDC0DE64/websocket_client_change_ping_interval
Add methods to allow get/set of websocket client ping interval (IDFGH-7096)
This commit is contained in:
@ -917,6 +917,38 @@ bool esp_websocket_client_is_connected(esp_websocket_client_handle_t client)
|
||||
return client->state == WEBSOCKET_STATE_CONNECTED;
|
||||
}
|
||||
|
||||
size_t esp_websocket_client_get_ping_interval_sec(esp_websocket_client_handle_t client)
|
||||
{
|
||||
if (client == NULL) {
|
||||
ESP_LOGW(TAG, "Client was not initialized");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (client->config == NULL) {
|
||||
ESP_LOGW(TAG, "No config available to change the ping interval");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return client->config->ping_interval_sec;
|
||||
}
|
||||
|
||||
esp_err_t esp_websocket_client_set_ping_interval_sec(esp_websocket_client_handle_t client, size_t ping_interval_sec)
|
||||
{
|
||||
if (client == NULL) {
|
||||
ESP_LOGW(TAG, "Client was not initialized");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (client->config == NULL) {
|
||||
ESP_LOGW(TAG, "No config available to change the ping interval");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
client->config->ping_interval_sec = ping_interval_sec == 0 ? WEBSOCKET_PING_INTERVAL_SEC : ping_interval_sec;
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_websocket_register_events(esp_websocket_client_handle_t client,
|
||||
esp_websocket_event_id_t event,
|
||||
esp_event_handler_t event_handler,
|
||||
|
Reference in New Issue
Block a user