feat(framework): core 最小集协议类型(envelope/login)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-28 14:20:54 +08:00
co-authored by Claude Opus 4.8
parent f693f45895
commit 56dbfeb5e2
3 changed files with 51 additions and 0 deletions
@@ -0,0 +1,16 @@
import type { RouteName } from '../constants.ts';
/** 客户端→服务器 单层信封。来源 docs/protocol/01 §3.1。 */
export interface OutboundEnvelope<T = unknown> {
app: 'youle';
route: RouteName | string; // 游戏内 route 为子游戏名
rpc: string;
data: T;
}
/** 服务器→客户端 解包后的内层。来源 docs/protocol/01 §3.2。 */
export interface InboundMessage<T = unknown> {
route: string;
rpc: string;
data: T;
}
@@ -0,0 +1,26 @@
/**
* player_login 请求/响应(最小集)。完整字段以 docs/protocol/01 §6、02、04 为准(spec §0.1)。
* 用索引签名容纳本最小集未显式列出的协议字段,避免在此内联复制全部协议字段。
*/
export interface LoginRequestData {
agentid: number | string;
gameid: number | string;
openid: string;
nickname: string;
avatar: string;
sex: number;
province: string;
city: string;
unionid: string | number;
version: string;
channelid: number | string;
marketid: number | string;
[extra: string]: unknown; // location/ip/machineid/telphone 等由 Send_login 注入,见 docs/protocol/01 §6
}
/** 登录响应 A 组账号资产(核心字段)。完整见 docs/protocol/04。 */
export interface LoginResponseData {
state: number; // 0=成功
playerid: number;
[extra: string]: unknown; // bean/roomcard/charm/... 及 B 组房间恢复字段 roomcode/isbattle/deskinfo
}
@@ -0,0 +1,9 @@
import type { OutboundEnvelope, InboundMessage } from '../../YouleNexus/assets/framework/core/types/envelope.ts';
import type { LoginRequestData, LoginResponseData } from '../../YouleNexus/assets/framework/core/types/login.ts';
const out: OutboundEnvelope<LoginRequestData> = {
app: 'youle', route: 'agent', rpc: 'player_login',
data: { agentid: 1, gameid: 2, openid: 'o', nickname: 'n', avatar: 'a', sex: 0, province: '', city: '', unionid: 'u', version: '1', channelid: 0, marketid: 0 },
};
const inb: InboundMessage<LoginResponseData> = { route: 'agent', rpc: 'player_login', data: { state: 0, playerid: 9 } };
void out; void inb;