Bwuh
This commit is contained in:
parent
096e69259f
commit
e0ce204118
6
index.js
6
index.js
|
@ -27,7 +27,9 @@ app.put('/api/connect/:jobid', (req, res) => {
|
||||||
ws_[id].message = data;
|
ws_[id].message = data;
|
||||||
})
|
})
|
||||||
ws_[id].connection.on('close', function() {
|
ws_[id].connection.on('close', function() {
|
||||||
|
if (ws_[id].connection) {
|
||||||
ws_[id].connection.terminate();
|
ws_[id].connection.terminate();
|
||||||
|
}
|
||||||
})
|
})
|
||||||
ws_[id].open = false;
|
ws_[id].open = false;
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
|
@ -54,10 +56,10 @@ app.post("/api/send/:jobid/:id/", (req, res) => {
|
||||||
var socket = ws_[id].connection;
|
var socket = ws_[id].connection;
|
||||||
console.log("sent data: " + req.body)
|
console.log("sent data: " + req.body)
|
||||||
if (stats.open == true) {
|
if (stats.open == true) {
|
||||||
socket.send(req.body);
|
socket.send(req.body.data);
|
||||||
} else {
|
} else {
|
||||||
socket.on('open', () => {
|
socket.on('open', () => {
|
||||||
socket.send(req.body);
|
socket.send(req.body.data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
res.send({
|
res.send({
|
||||||
|
|
Loading…
Reference in a new issue