s00500 / ESPUI

A simple web user interface library for ESP32 and ESP8266
https://valencia.lbsfilm.at/midterm-presentation/
Other
896 stars 166 forks source link

Cleanup of disconnected clients #301

Closed ChrSchu90 closed 3 months ago

ChrSchu90 commented 3 months ago

If a client reloads the page by using F5 a new connection will be created, but the old one will not trigger a disconnect. This leads into high memory usage and could cause a crash depending on the UI size and amount of reloads. To trigger a disconnect of old clients the AsyncWebSocket.cleanupClients() will now be called on every connect.

Debug output before change:

UI Initialized
ESPUIclient::OnWsEvent:WS_EVT_CONNECT
1
ESPUIclient::OnWsEvent:WS_EVT_CONNECT
2
ESPUIclient::OnWsEvent:WS_EVT_CONNECT
3

Debug output after change:

UI Initialized
ESPUIclient::OnWsEvent:WS_EVT_CONNECT
1
WS_EVT_DISCONNECT
ESPUIclient::OnWsEvent:WS_EVT_CONNECT
2
WS_EVT_DISCONNECT
ESPUIclient::OnWsEvent:WS_EVT_CONNECT
3
s00500 commented 3 months ago

Hey @ChrSchu90, thanks that looks like it was missing!

@MartinMueller2003 any concerns here ? :-) Else LGTM

s00500 commented 3 months ago

Ok, thanks for the detailed info, I guess this is better than nothing for now anyways :-)