feat(framework): net Transport 接口 + 测试用 FakeTransport

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-28 14:22:47 +08:00
co-authored by Claude Opus 4.8
parent 7dcdeb6615
commit 90843374f9
3 changed files with 77 additions and 0 deletions
@@ -0,0 +1,14 @@
/**
* WebSocket 抽象(依赖注入点,D2)。
* 生产:Cocos/浏览器 WebSocket adapter(见 cocos-transport.ts)。
* 测试:内存 FakeTransport(模拟 server)。
*/
export interface Transport {
send(frame: string): void;
close(): void;
onOpen(cb: () => void): void;
onMessage(cb: (frame: string) => void): void;
onClose(cb: () => void): void;
/** 发起连接(建立后应触发 onOpen)。 */
connect(url: string): void;
}