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; const chunkOffset = cx + cy * this.firstZoomtileWidth;
if (~queue.indexOf(chunkOffset)) return; if (~queue.indexOf(chunkOffset)) return;
queue.push(chunkOffset); queue.push(chunkOffset);
/*
logger.info( logger.info(
`Tiling: Enqueued ${cx}, ${cy} / ${this.id} for basezoom reload`, `Tiling: Enqueued ${cx}, ${cy} / ${this.id} for basezoom reload`,
); );
*/
} }
/* /*

View File

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

View File

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

View File

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