mairas/ReactESP

ESP8266WebServer handle client

Closed this issue · 3 comments

Hi, I like to use your lib to handle a client, which connects to the AP.

Could you please could help with the proper syntax of the app.on...... statement?

I tried something like:
app.onAvailable(&server, [] () {
server.handleClient();

.onAvailable adds a reaction for Arduino-like streams and is most likely not what you want. It's a bit difficult to tell what exactly you are trying to do but you might want to have a look at https://github.com/SignalK/SensESP. It's a project that uses ReactESP extensively. If you search that repository for "app.on", you'll find a ton of examples on different use cases. Some of them might be a bit complex but others should be quite understandable.

Thanx for your answer.
What I like to achieve is the following.
Parallel to a program running on the ESP I like to set up a wifi access point (socket) and listen to a client to connect.
But because the listen statement is blocking the complete program. To this I have no solution.

With your lib I hope to overcome this blocking. E.g. if a client likes to connect, a construct like this maybe helps.
app.onAvailable(&server, [] () {
server.handleClient();
The idea is: if a server is available, the ESP responces.

The link to SenseESP did not give me an idea to solve it.

You can't use blocking calls, because they will stop the loop execution. This means you can't use a blocking server to achieve asynchronous execution. The callback will not create a thread that could handle this case.

The better way would be to use existing async HTTP server library like https://github.com/me-no-dev/ESPAsyncWebServer