Procházet zdrojové kódy

Merge branch 'feature/websocket_server_support_close_handle_v4.4' into 'release/v4.4'

esp_http_server: Websocket CLOSE frame can support callback function (backport v4.4)

See merge request espressif/esp-idf!17339
Mahavir Jain před 4 roky
rodič
revize
a472035d97
1 změnil soubory, kde provedl 2 přidání a 5 odebrání
  1. 2 5
      components/esp_http_server/src/httpd_parse.c

+ 2 - 5
components/esp_http_server/src/httpd_parse.c

@@ -756,13 +756,10 @@ esp_err_t httpd_req_new(struct httpd_data *hd, struct sock_db *sd)
         ret = httpd_ws_get_frame_type(r);
         ESP_LOGD(TAG, LOG_FMT("New WS request from existing socket, ws_type=%d"), ra->ws_type);
 
-        /*  Stop and return here immediately if it's a CLOSE frame */
         if (ra->ws_type == HTTPD_WS_TYPE_CLOSE) {
+            /*  Only mark ws_close to true if it's a CLOSE frame */
             sd->ws_close = true;
-            return ret;
-        }
-
-        if (ra->ws_type == HTTPD_WS_TYPE_PONG) {
+        } else if (ra->ws_type == HTTPD_WS_TYPE_PONG) {
             /* Pass the PONG frames to the handler as well, as user app might send PINGs */
             ESP_LOGD(TAG, LOG_FMT("Received PONG frame"));
         }