From e0ce20411847f6bd158cda5d2f4128d76653caa5 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Wed, 4 Sep 2024 08:02:09 -0600 Subject: [PATCH] Bwuh --- index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 20b2651..b05f7bb 100644 --- a/index.js +++ b/index.js @@ -27,7 +27,9 @@ app.put('/api/connect/:jobid', (req, res) => { ws_[id].message = data; }) ws_[id].connection.on('close', function() { - ws_[id].connection.terminate(); + if (ws_[id].connection) { + ws_[id].connection.terminate(); + } }) ws_[id].open = false; setInterval(() => { @@ -54,10 +56,10 @@ app.post("/api/send/:jobid/:id/", (req, res) => { var socket = ws_[id].connection; console.log("sent data: " + req.body) if (stats.open == true) { - socket.send(req.body); + socket.send(req.body.data); } else { socket.on('open', () => { - socket.send(req.body); + socket.send(req.body.data); }); } res.send({