fix(framework): kick_server 终止不重连(对齐真实客户端)

收到 kick_server 时 emit kicked 并 stop(),不再 onClose→重连→重踢空转。
kick 处理移出登录门控,登录态内外一致。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-28 20:37:16 +08:00
co-authored by Claude Opus 4.8
parent ad661707ec
commit 883335f656
2 changed files with 20 additions and 2 deletions
@@ -124,6 +124,24 @@ test('TcpID 去重:旧连接的残留包被丢弃', async () => {
assert.equal(messages.length, 0);
});
test('kick_server:emit kicked 且不再自动重连', async () => {
const t1 = new FakeTransport(), t2 = new FakeTransport();
const { clock, advance } = fakeClock();
const client = makeClient([t1, t2], clock);
let kicked = 0;
client.on('kicked', () => { kicked++; });
client.start();
await t1.flush();
// 服务器踢人(登录态期间)
t1.serverPush(JSON.stringify({ route: 'agent', rpc: 'kick_server', data: { msg: 'x' } }));
await t1.flush();
assert.equal(kicked, 1);
// 推进重连/超时定时器 → 不应建立新连接或重发 login
advance(30000); advance(10000);
await t2.flush();
assert.equal(t2.sent.length, 0);
});
test('debug=true 记录 send 与 recv(注入 logger)', async () => {
const t = new FakeTransport();
const { clock } = fakeClock();