My video streaming app does use server.sendContent(); to stream mjpeg pictures. This is done in a loop inside the webserver handler. This loop continues to send even if the client disconnects. How do i prevent this?
Using "WiFiServer" there is client.available() and client.connected() to check this.
Using "esp_http_server.h" the httpd_resp_send_chunk function gives the return ESP_OK on sucess.
How do i replicate this functionality with "WebServer.h"?
Or can i make the OTA updater functional with "WiFiServer" or "esp_http_server.h" ?
WebServer.h how do i know if a client disconnects?
-
- Posts: 20
- Joined: Mon Sep 18, 2023 3:54 am
-
- Posts: 828
- Joined: Mon Jul 22, 2019 3:20 pm
Re: WebServer.h how do i know if a client disconnects?
I am not so familiar with the code to have a quick answer for you, but the WiFiClient that WebServer is using is public, so in theory you should be able to look at that object to see if it is connected.
As far as an IDF-based wifi manager, esp-wifi-manager can be included in a project as a component.
As far as an IDF-based wifi manager, esp-wifi-manager can be included in a project as a component.
-
- Posts: 20
- Joined: Mon Sep 18, 2023 3:54 am
Re: WebServer.h how do i know if a client disconnects?
lbernstone wrote: ↑Sun Mar 17, 2024 7:25 pmthe WiFiClient that WebServer is using is public, so in theory you should be able to look at that object to see if it is connected.
TY. That might exceed my talent. Will try.
Project:
http video:
https://youtu.be/NCWrQaDqzJg
external video:
https://youtube.com/shorts/Xo_1b1SBKy8
-
- Posts: 828
- Joined: Mon Jul 22, 2019 3:20 pm
Re: WebServer.h how do i know if a client disconnects?
Code: Select all
#include <WebServer.h>
WebServer server(80);
void handleRoot() {
WiFiClient wfc = server.client();
if (wfc.connected()) {
Serial.print("Remote IP: ");
Serial.println(wfc.remoteIP());
}
server.send(200, "text/plain", "Hello!\n");
}
void setup() {
Serial.begin(115200);
WiFi.begin("larryb","clownfish");
WiFi.waitForConnectResult();
Serial.println(WiFi.localIP());
server.on("/", HTTP_ANY, [](){handleRoot();});
server.begin();
}
void loop() {
server.handleClient();
delay(100);
}
-
- Posts: 20
- Joined: Mon Sep 18, 2023 3:54 am
Re: WebServer.h how do i know if a client disconnects?
Code: Select all
while(wfc.connected())
{
Next thing is mounting esp32cam on this:
- Attachments
-
- IMG_20240312_061210.jpg (486.33 KiB) Viewed 1270 times
Who is online
Users browsing this forum: No registered users and 113 guests