Fixed client disconnect and navigation glitch
This commit is contained in:
parent
ecf0516b39
commit
a3cb448a7b
8 changed files with 34 additions and 39 deletions
|
@ -1,4 +1,4 @@
|
|||
import { Manager } from "socket.io-client";
|
||||
import { io } from "socket.io-client";
|
||||
import modes from "../modes.js";
|
||||
import events from "../events.js";
|
||||
|
||||
|
@ -21,17 +21,20 @@ export default class Initiator {
|
|||
}
|
||||
|
||||
async newJob(jobRequest, onLog, onClose, onCreate) {
|
||||
const mgr = new Manager(this.url, {
|
||||
query: { mode: this.mode, job: JSON.stringify(jobRequest) },
|
||||
});
|
||||
onLog = onLog ?? this.onLog.bind(this);
|
||||
onClose = onClose ?? this.onClose.bind(this);
|
||||
onCreate = onCreate ?? this.onCreate.bind(this);
|
||||
this.sk = mgr.socket("/");
|
||||
this.sk.on(events.JOB_LOG, onLog);
|
||||
this.sk.on(events.JOB_CLS, onClose);
|
||||
const sk = io(this.url, {
|
||||
query: { mode: this.mode, job: JSON.stringify(jobRequest) },
|
||||
});
|
||||
sk.on(events.JOB_LOG, onLog);
|
||||
sk.on(events.JOB_CLS, function onJobClose(c) {
|
||||
sk.disconnect();
|
||||
onClose(c);
|
||||
});
|
||||
this.sk = sk;
|
||||
return new Promise((res) =>
|
||||
this.sk.on(events.JOB_CRT, function onJobCreate(id) {
|
||||
sk.on(events.JOB_CRT, function onJobCreate(id) {
|
||||
onCreate(id);
|
||||
res({ ...jobRequest, id });
|
||||
})
|
||||
|
@ -46,9 +49,6 @@ export default class Initiator {
|
|||
onPipelineTrigger,
|
||||
onPipelineClose
|
||||
) {
|
||||
const mgr = new Manager(this.url, {
|
||||
query: { mode: this.mode, job: JSON.stringify(jobRequest) },
|
||||
});
|
||||
onLog = onLog ?? this.onLog.bind(this);
|
||||
onClose = onClose ?? this.onClose.bind(this);
|
||||
onCreate = onCreate ?? this.onCreate.bind(this);
|
||||
|
@ -85,13 +85,18 @@ export default class Initiator {
|
|||
}
|
||||
});
|
||||
onPipelineClose = onPipelineClose ?? this.onPipelineClose.bind(this);
|
||||
this.sk = mgr.socket("/");
|
||||
this.sk.on(events.JOB_LOG, onLog);
|
||||
this.sk.on(events.JOB_CLS, onClose);
|
||||
this.sk.on(events.PPL_TRG, onPipelineTrigger);
|
||||
this.sk.on(events.PPL_CLS, onPipelineClose);
|
||||
const sk = io(this.url, {
|
||||
query: { mode: this.mode, job: JSON.stringify(jobRequest) },
|
||||
});
|
||||
sk.on(events.JOB_LOG, onLog);
|
||||
sk.on(events.JOB_CLS, function onJobClose(c) {
|
||||
sk.disconnect();
|
||||
onClose(c);
|
||||
});
|
||||
sk.on(events.PPL_TRG, onPipelineTrigger);
|
||||
this.sk = sk;
|
||||
return new Promise((res) =>
|
||||
this.sk.on(events.JOB_CRT, function onJobCreate(id) {
|
||||
sk.on(events.JOB_CRT, function onJobCreate(id) {
|
||||
onCreate(id);
|
||||
res({ ...jobRequest, id });
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue