Do thing to fix thing
This commit is contained in:
parent
f69cc9c451
commit
5e7a0576e5
15
index.js
15
index.js
|
@ -29,6 +29,7 @@ app.put('/api/connect/:jobid', (req, res) => {
|
||||||
ws_[id].connection.on('close', function() {
|
ws_[id].connection.on('close', function() {
|
||||||
if (ws_[id]) {
|
if (ws_[id]) {
|
||||||
ws_[id].connection.terminate();
|
ws_[id].connection.terminate();
|
||||||
|
delete ws_[id];
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
ws_[id].open = false;
|
ws_[id].open = false;
|
||||||
|
@ -44,6 +45,13 @@ app.put('/api/connect/:jobid', (req, res) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post("/api/send/:jobid/:id/", (req, res) => {
|
app.post("/api/send/:jobid/:id/", (req, res) => {
|
||||||
|
if (!ws_[req.params.id]) {
|
||||||
|
res.status(404).send({
|
||||||
|
success: false,
|
||||||
|
message: "Invalid ID"
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (ws_[req.params.id].jobid !== req.params.jobid) {
|
if (ws_[req.params.id].jobid !== req.params.jobid) {
|
||||||
res.status(401).send({
|
res.status(401).send({
|
||||||
success: false,
|
success: false,
|
||||||
|
@ -76,6 +84,13 @@ app.post("/api/send/:jobid/:id/", (req, res) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
app.get("/api/poll/:jobid/:id", (req, res) => {
|
app.get("/api/poll/:jobid/:id", (req, res) => {
|
||||||
|
if (!ws_[req.params.id]) {
|
||||||
|
res.status(404).send({
|
||||||
|
success: false,
|
||||||
|
message: "Invalid ID"
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (ws_[req.params.id].jobid !== req.params.jobid) {
|
if (ws_[req.params.id].jobid !== req.params.jobid) {
|
||||||
res.status(401).send({
|
res.status(401).send({
|
||||||
success: false,
|
success: false,
|
||||||
|
|
Loading…
Reference in a new issue