From 8eb35f4da377ead92ffd274326c2331d6d2ecc54 Mon Sep 17 00:00:00 2001 From: Eunchong Kim Date: Sun, 8 Aug 2021 14:14:49 +0900 Subject: [PATCH] Fixed json send bug --- ws_server.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ws_server.js b/ws_server.js index c327658..c7bd7a2 100644 --- a/ws_server.js +++ b/ws_server.js @@ -46,9 +46,10 @@ wss.on('connection', (ws) => { setInterval( () => { var data = { ctrl: 'idle', - time: new Date().toTimeString() + date: new Date() } wss.clients.forEach( (client) => { - client.send( data ); + // Send the msg object as a JSON-formatted string. + client.send( JSON.stringify( data ) ); }); }, 30000); // 30 s