1
0
mirror of https://github.com/s00500/ESPUI.git synced 2024-12-23 00:40:49 +00:00

#5 fixing textThem to function properly

This commit is contained in:
Lukas Bachschwell 2017-12-26 21:10:54 +01:00
parent 679bf1a5c1
commit c72bff5b2e

View File

@ -95,12 +95,17 @@ void onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client,
Serial.printf("Disconnected!\n");
break;
case WS_EVT_CONNECT: {
if (debug)
Serial.println("Connected");
if (debug){
Serial.print("Connected: ");
Serial.println(client->id());
}
ESPUI.jsonDom(client);
if (debug)
if (debug){
Serial.println("JSON Data Sent to Client!");
} break;
}
}
break;
case WS_EVT_DATA:
String msg = "";
for (size_t i = 0; i < len; i++) {
@ -337,11 +342,17 @@ void ESPUIClass::updateSwitcher(String label, bool nValue, int clientId) {
updateSwitcher(getIdByLabel(label), nValue, clientId);
}
// This is a hacky workaround because ESPAsyncWebServer does not have a function like this and it's clients array is private
void ESPUIClass::textThem(String text, int clientId){
for(int i = 1; i <= this->ws->count(); i++){
if(clientId!=i){
this->ws->client(i)->text(text);
int tryId = 0;
for(int count = 0; count < this->ws->count();){
if(this->ws->hasClient(tryId)) {
if(clientId!=tryId){
this->ws->client(tryId)->text(text);
}
count++;
}
tryId++;
}
}