Send number of running jobs on init payload
This commit is contained in:
parent
6d1bc63352
commit
e692077ed5
3 changed files with 6 additions and 3 deletions
|
@ -30,7 +30,7 @@ A client sends *requests* (T-messages) to a server, which subsequently *replies*
|
|||
- Rcancel tag[2]
|
||||
- Twait tag[2] jid[4]
|
||||
- Rwait tag[2]
|
||||
- Rinit tag[2] max_jobs[2] formats[j]
|
||||
- Rinit tag[2] max_jobs[2] running_jobs[2] formats[j]
|
||||
|
||||
### Job Object
|
||||
The job object is formatted like this:
|
||||
|
|
|
@ -91,11 +91,13 @@ wss.on("connection", (ws, request) => {
|
|||
log(`WS client ${request.socket.remoteAddress}:${request.socket.remotePort} has connected`);
|
||||
const num = Buffer.alloc(2);
|
||||
num.writeUInt16LE(MAX_JOBS);
|
||||
const cur = Buffer.alloc(2);
|
||||
cur.writeUInt16LE(jobAmount);
|
||||
const formats = {};
|
||||
for (const cmd of Object.keys(magick)) {
|
||||
formats[cmd] = ["image/png", "image/gif", "image/jpeg", "image/webp"];
|
||||
}
|
||||
const init = Buffer.concat([Buffer.from([Rinit]), Buffer.from([0x00, 0x00]), num, Buffer.from(JSON.stringify(formats))]);
|
||||
const init = Buffer.concat([Buffer.from([Rinit]), Buffer.from([0x00, 0x00]), num, cur, Buffer.from(JSON.stringify(formats))]);
|
||||
ws.send(init);
|
||||
|
||||
ws.on("error", (err) => {
|
||||
|
|
|
@ -63,7 +63,8 @@ class ImageConnection {
|
|||
const op = msg.readUint8(0);
|
||||
if (op === Rinit) {
|
||||
this.max = msg.readUint16LE(3);
|
||||
this.formats = JSON.parse(msg.toString("utf8", 5));
|
||||
this.njobs = msg.readUint16LE(5);
|
||||
this.formats = JSON.parse(msg.toString("utf8", 7));
|
||||
return;
|
||||
}
|
||||
const tag = msg.readUint16LE(1);
|
||||
|
|
Loading…
Reference in a new issue