feat: add world voxel snapshot forwarding

Collect chunk voxel data from the bot world and stream snapshot,
chunk, and unwatch messages through the forward protocol.
This commit is contained in:
2026-10-23 10:44:37 +08:00
parent 0acef64f48
commit 6c69afb38a
11 changed files with 1997 additions and 18 deletions
+23
View File
@@ -678,3 +678,26 @@ test('context disposal reports offline once even when no instance was created',
assert.equal(await context.connect(), 467);
}
});
test('throwing log observers cannot interrupt socketClosed cleanup or offline reporting', async () => {
const {context, bots, statuses, managers, functions, timers} = setup();
await context.connect();
bots[0].emit('initialLogin');
const written = [];
context.logger.log = segments => written.push(...segments);
context.on('log', () => { throw new Error('log observer failed'); });
let lost = 0;
context.on('connection_lost', () => lost++);
assert.doesNotThrow(() => bots[0].emit('end', 'socketClosed'));
await flush();
assert.equal(context.bot_instance, null);
assert.equal(context.bot_status, 'offline');
assert.deepEqual(statuses.slice(-2), ['disconnecting', 'offline']);
assert.ok(written.includes('连接已断开: socketClosed'));
assert.ok(written.includes('[NODE] 机器人实例已关闭'));
assert.equal(managers[0].disposed, true);
assert.equal(functions[0].disposed, true);
assert.equal(lost, 1);
assert.equal(timers.size, 0);
await context.clear_this_context();
});