1
0
mirror of https://github.com/s00500/ESPUI.git synced 2025-07-03 19:50:20 +00:00

3 Commits
1.4.2 ... 1.4.3

Author SHA1 Message Date
851c363aba version bump 2017-12-26 21:14:06 +01:00
c72bff5b2e #5 fixing textThem to function properly 2017-12-26 21:10:54 +01:00
679bf1a5c1 fixed single quotes 2017-12-26 19:35:53 +01:00
2 changed files with 20 additions and 9 deletions

View File

@ -1,5 +1,5 @@
name=ESPUI
version=1.4.2
version=1.4.3
author=Lukas Bachschwell
maintainer=Lukas Bachschwell <lukas@lbsfilm.at>
sentence=ESP32 and ESP8266 Web Interface Library

View File

@ -49,7 +49,7 @@ void writeFile(fs::FS &fs, const char * path, const char * data){
void ESPUIClass::prepareFileSystem(){
// this function should only be used once
Serial.println('About to prepare filesystem...');
Serial.println("About to prepare filesystem...");
#if defined(ESP32)
if(!SPIFFS.begin(true)) {
@ -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++;
}
}