mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-07-13 18:46:32 +02:00
Add methods to allow get/set of websocket client ping interval
This commit is contained in:
@ -902,6 +902,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