fix(framework): decodeFrame 改单层(服务器协议非双层)
真机联调发现:服务器实发单层 {app,route,rpc,data};旧客户端的'外层 data'是浏览器
MessageEvent(00_minhttp.js:266 ws.onmessage=config.onmessage),非协议层。框架传输层
已取 ev.data,decodeFrame 不应再剥一层。修正后 kick_server 等业务包能正确解析。
- decodeFrame 单层化 + 测试改单层帧
- 更正 docs/protocol/01 §3.2(双层→单层,附 MessageEvent 依据)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -21,18 +21,18 @@ test('login 全流程:握手→登录→业务包,且 parseLoginResponse 识
|
||||
client.start();
|
||||
await t.flush();
|
||||
|
||||
// 服务器先发握手包(应被忽略)
|
||||
t.serverPush(JSON.stringify({ data: '@toconconHELLO' }));
|
||||
// 服务器先发握手包(原始串,应被忽略)
|
||||
t.serverPush('@toconconHELLO');
|
||||
await t.flush();
|
||||
|
||||
// 客户端应已发出 player_login
|
||||
assert.equal(JSON.parse(t.sent[0]).rpc, 'player_login');
|
||||
|
||||
// 服务器回 login 响应(带房间恢复 + 对局)
|
||||
t.serverPush(JSON.stringify({ data: JSON.stringify({
|
||||
// 服务器回 login 响应(单层,带房间恢复 + 对局)
|
||||
t.serverPush(JSON.stringify({
|
||||
route: 'agent', rpc: 'player_login',
|
||||
data: { state: 0, playerid: 42, bean: 500, roomcode: 'ROOM1', isbattle: 1, deskinfo: { round: 3 } },
|
||||
}) }));
|
||||
}));
|
||||
await t.flush();
|
||||
|
||||
assert.ok(loginData);
|
||||
@@ -43,10 +43,10 @@ test('login 全流程:握手→登录→业务包,且 parseLoginResponse 识
|
||||
assert.equal(parsed.hasBattle, true);
|
||||
assert.deepEqual(parsed.deskinfo, { round: 3 });
|
||||
|
||||
// 心跳包(忽略,不进 business)
|
||||
t.serverPush(JSON.stringify({ data: JSON.stringify({ com: '@serverheartbeat' }) }));
|
||||
// 正常业务推送(门控已清,放行)
|
||||
t.serverPush(JSON.stringify({ data: JSON.stringify({ route: 'room', rpc: 'other_join_room', data: { seat: 2 } }) }));
|
||||
// 心跳包(单层,忽略,不进 business)
|
||||
t.serverPush(JSON.stringify({ com: '@serverheartbeat' }));
|
||||
// 正常业务推送(单层,门控已清,放行)
|
||||
t.serverPush(JSON.stringify({ route: 'room', rpc: 'other_join_room', data: { seat: 2 } }));
|
||||
await t.flush();
|
||||
|
||||
assert.equal(business.length, 1);
|
||||
|
||||
Reference in New Issue
Block a user