Description
This is a request for support of HTML5 Server Sent Events aka Event Source.
It allows e.g. to implement an event bus over HTML.
The required changes to the ESP8266WebServer library are absolutely minimal: zero impact on existing code and increase in code size/memory footprint of just few bytes (basically sizeof bool).
Essentially, the variable bool keepCurrentClient which is currently hardcoded to false, becomes a protected class variable in the ESP8266WebServer class that can be modified via a new function called keepCurrentClient(bool).
To enable Server Sent Events/event subscription, it requires two web server instances, one being changed to keep the client socket/session (an event listener) open until disconnected.
ESP8266WebServer _server(port);
ESP8266WebServer _SSEserver(port + 1);
_server.begin();
_SSEserver.keepCurrentClient(true);
_SSEserver.begin();
Everything else can implemented in user code (event subscription, event bus keepalive messages, event payload etc.).
I have this currently working on a clean fork from master branch with just this one change.
Happy to post a PR (it's ready to post), if this is a reasonable request.
I can also contribute a working example, I suppose in the ESP8266WebServer examples section.
Thanks once again for this brilliant library and for taking the time to consider this request,
Ewald