Merge branch 'master' into devel

This commit is contained in:
HF 2022-09-11 17:22:55 +02:00
commit 96c6aaa23e
4 changed files with 11 additions and 9 deletions

View File

@ -131,9 +131,11 @@ class CanvasUpdater {
const chunkOffset = cx + cy * this.firstZoomtileWidth;
if (~queue.indexOf(chunkOffset)) return;
queue.push(chunkOffset);
/*
logger.info(
`Tiling: Enqueued ${cx}, ${cy} / ${this.id} for basezoom reload`,
);
*/
}
/*

View File

@ -78,6 +78,7 @@ class MessageBroker extends SocketEvents {
}
if (!this.shards[message]) {
console.log(`CLUSTER: Shard ${message} connected`);
this.shards[message] = Date.now();
await this.subscriber.subscribe(
message,
(buffer) => this.onShardBinaryMessage(buffer, message),
@ -85,6 +86,7 @@ class MessageBroker extends SocketEvents {
);
// immediately give new shards informations
this.publisher.publish('bc', this.thisShard);
return;
}
this.shards[message] = Date.now();
return;
@ -129,9 +131,8 @@ class MessageBroker extends SocketEvents {
}
onShardBinaryMessage(buffer, shard) {
if (buffer.byteLength === 0) return;
const opcode = buffer[0];
try {
const opcode = buffer[0];
switch (opcode) {
case PixelUpdateMB.OP_CODE: {
const puData = PixelUpdateMB.hydrate(buffer);

View File

@ -471,10 +471,8 @@ class SocketServer {
}
async onBinaryMessage(buffer, ws) {
if (buffer.byteLength === 0) return;
const opcode = buffer[0];
try {
const opcode = buffer[0];
switch (opcode) {
case PixelUpdate.OP_CODE: {
const { canvasId, user } = ws;

View File

@ -12,19 +12,20 @@ export default {
*/
hydrate(data) {
const canvasId = data[1];
const chunk = [data[2], data[3]];
return [canvasId, chunk];
const i = data.readUInt8(2);
const j = data.readUInt8(3);
return [canvasId, [i, j]];
},
/*
* @param canvasId,
* chunkid id consisting of chunk coordinates
*/
dehydrate(canvasId, [i, j]) {
return Buffer.from({
return Buffer.from([
OP_CODE,
canvasId,
i,
j,
});
]);
},
};