Compare commits

...

2 Commits
master ... test

Author SHA1 Message Date
HF
d6eb9510fd debug 2023-03-18 12:17:59 +01:00
HF
3b26d3486c fix some eqeqeq and add store to window for debugging 2023-03-18 11:16:42 +01:00
7 changed files with 19 additions and 10 deletions

View File

@ -52,6 +52,10 @@ persistStore(store, {}, () => {
store.dispatch(fetchMe());
socketClient.initialize(store, pixelTransferController, getRenderer);
// for debugging
window.ppStore = store;
window.ppRender = getRenderer;
});
(function load() {

View File

@ -99,5 +99,5 @@ export const APISOCKET_USER_NAME = 'apisocket';
// maximum chunks to subscribe to
export const MAX_LOADED_CHUNKS = 2000;
export const MAX_CHUNK_AGE = 300000;
export const GC_INTERVAL = 300000;
export const MAX_CHUNK_AGE = 20000;
export const GC_INTERVAL = 20000;

View File

@ -160,8 +160,7 @@ export default async function drawByOffsets(
}
/* dont rank antarctica */
// eslint-disable-next-line eqeqeq
if (canvasId == 0 && y > 14450) {
if (canvasId === 0 && y > 14450) {
ranked = false;
}
}

View File

@ -363,8 +363,7 @@ class SocketServer {
broadcastPixelBuffer(canvasId, chunkid, data) {
if (this.CHUNK_CLIENTS.has(chunkid)) {
const clients = this.CHUNK_CLIENTS.get(chunkid)
// eslint-disable-next-line eqeqeq
.filter((ws) => ws.canvasId == canvasId);
.filter((ws) => ws.canvasId === canvasId);
SocketServer.broadcastSelected(clients, data);
}
}
@ -408,9 +407,9 @@ class SocketServer {
while (!client.done) {
const ws = client.value;
if (ws.readyState === WebSocket.OPEN
&& ws.user
&& ws.user && ws.canvasId !== null
) {
const canvasId = ws.canvasId || 0;
const { canvasId } = ws;
const { ip } = ws.user;
// only count unique IPs per canvas
if (!ipsPerCanvas[canvasId]) {
@ -580,7 +579,7 @@ class SocketServer {
case REG_CANVAS_OP: {
const canvasId = hydrateRegCanvas(buffer);
if (!canvases[canvasId]) return;
if (ws.canvasId !== null && ws.canvasId !== canvasId) {
if (ws.canvasId !== canvasId) {
this.deleteAllChunks(ws);
}
ws.canvasId = canvasId;
@ -638,6 +637,7 @@ class SocketServer {
}
deleteChunk(chunkid, ws) {
console.log('delete chunk', (chunkid >> 8) & 0x00FF, chunkid & 0x00FF, 'for', ws.user.ip);
ws.chunkCnt -= 1;
if (!this.CHUNK_CLIENTS.has(chunkid)) return;
const clients = this.CHUNK_CLIENTS.get(chunkid);
@ -647,6 +647,7 @@ class SocketServer {
deleteAllChunks(ws) {
if (!ws.chunkCnt) return;
console.logger('delete all chunks for', ws.user.ip);
// eslint-disable-next-line
for (const client of this.CHUNK_CLIENTS.values()) {
const pos = client.indexOf(ws);

View File

@ -219,6 +219,7 @@ export function requestBigChunk(center) {
}
export function removeChunks(chunks) {
console.log('remove chunks');
return {
type: 'REMOVE_CHUNKS',
chunks,

View File

@ -17,7 +17,9 @@ export default (store) => (next) => (action) => {
}
case 'REMOVE_CHUNKS': {
console.log('do');
const { chunks } = action;
console.log('deregister', chunks.filter((chunk) => chunk.recUpdates).map((chunk) => [chunk.i, chunk.j]));
const ids = chunks
.filter((chunk) => chunk.recUpdates)
.map((chunk) => chunk.id);

View File

@ -122,7 +122,9 @@ class ChunkLoader {
}
}
});
this.bcRemoveChunks(remChunks);
if (remChunks.length) {
this.bcRemoveChunks(remChunks);
}
// eslint-disable-next-line no-console,max-len
console.log(`GC cleaned ${remChunks.length} / ${chunks.size + remChunks.length} chunks`);
}