Skip to content

Commit

Permalink
Parse resize payload early
Browse files Browse the repository at this point in the history
  • Loading branch information
ku1ik committed Jan 19, 2025
1 parent 026d8c8 commit 0506708
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ function executeEvent(feed, resize) {
if (code === "o") {
feed(data);
} else if (code === "r") {
const [cols, rows] = data.split("x");
resize(cols, rows);
resize(data.cols, data.rows);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/driver/websocket/alis.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function alisHandler(buffer) {
const cols = view.getUint16(5, true);
const rows = view.getUint16(7, true);

return [time, "r", `${cols}x${rows}`];
return [time, "r", { cols, rows }];
} else if (type === 0x6d) {
// 'm' - marker
const time = view.getFloat32(1, true);
Expand Down
15 changes: 14 additions & 1 deletion src/driver/websocket/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,20 @@ function jsonHandler(buffer) {

const meta = { cols: header.width, rows: header.height, time: 0.0 };

return { meta, handler: JSON.parse };
return {
meta,

handler: function(buffer) {
const event = JSON.parse(buffer);

if (event[1] === "r") {
const [cols, rows] = event[2].split("x");
return [event[0], "r", { cols, rows }];
} else {
return event;
}
}
}
}

export { jsonHandler };

0 comments on commit 0506708

Please sign in to comment.