From ffd54f1abfda371f9d422cd3a64e842cdba6ba98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Sun, 5 Mar 2017 22:51:24 +0100 Subject: [PATCH] Do not broadcast messages via websocket if there is no client connected --- code/espurna/web.ino | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/code/espurna/web.ino b/code/espurna/web.ino index b1c99e0a..0e0a9b72 100644 --- a/code/espurna/web.ino +++ b/code/espurna/web.ino @@ -44,8 +44,10 @@ char _last_modified[50]; // ----------------------------------------------------------------------------- bool wsSend(const char * payload) { - DEBUG_MSG("[WEBSOCKET] Broadcasting '%s'\n", payload); - ws.textAll(payload); + if (ws.count() > 0) { + DEBUG_MSG("[WEBSOCKET] Broadcasting '%s'\n", payload); + ws.textAll(payload); + } } bool wsSend(uint32_t client_id, const char * payload) {