diff --git a/api/IMPLEMENTATION.md b/api/IMPLEMENTATION.md index da269e6..3104314 100644 --- a/api/IMPLEMENTATION.md +++ b/api/IMPLEMENTATION.md @@ -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: diff --git a/api/index.js b/api/index.js index dcf163e..f24e3f7 100644 --- a/api/index.js +++ b/api/index.js @@ -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) => { diff --git a/utils/imageConnection.js b/utils/imageConnection.js index 3482098..6c23b6e 100644 --- a/utils/imageConnection.js +++ b/utils/imageConnection.js @@ -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);