Closed happytm closed 3 years ago
Look at this wiki page
You can do server.poll()
, it will return either true
/false
indicating if there is a client waiting to connect :)
Thank you for your prompt reply. I ended up using advanced echo server adapting to my use case and it works fine.
Here is my loop code:
void loop() {
#if WEBSOCKETS
while (WSserver.available()) {
// if there is a client that wants to connect
if(WSserver.poll()) {
//accept the connection and register callback
Serial.println("Accepting a new client!");
WebsocketsClient client = WSserver.accept();
client.onMessage(onMessage);
// store it for later use
allClients.push_back(client);
}
// check for updates in all clients
pollAllClients();
if (triggerProcessData == 1) {
processData();
triggerProcessData = 0;
}
#if MQTT
broker.loop(); // Don't forget to add loop for every broker and clients
myClient.loop();
#endif
}
#endif
} // End of loop
Thanks again.
I am trying to use your server library but having problem with loop section which seems to block the call to a function processData() in my code. I read through wiki pages but could not figure it out.
Is there any way around it?
My loop looks like below:
Thanks.