update:对接个人训练改版
This commit is contained in:
@@ -20,6 +20,7 @@ export const ServerMessageType = {
|
||||
SERVER_MSG_PLAYER_LEFT: 11,
|
||||
SERVER_MSG_HEARTBEAT: 12,
|
||||
SERVER_MSG_PRACTICE_END: 13,
|
||||
SERVER_MSG_SYNC_PRACTICE_INFO: 14,
|
||||
};
|
||||
|
||||
export const ClientMessageType = {
|
||||
@@ -28,6 +29,7 @@ export const ClientMessageType = {
|
||||
CLIENT_MSG_SHOOT_DATA: 2,
|
||||
CLIENT_MSG_ACK: 3,
|
||||
CLIENT_MSG_LEAVE: 4,
|
||||
CLIENT_MSG_SYNC_PRACTICE_INFO: 5,
|
||||
};
|
||||
|
||||
// protobufjs 的 enum 默认是 name -> value,这里反转成 value -> name 用于日志打印。
|
||||
@@ -149,6 +151,38 @@ const SCHEMAS = {
|
||||
9: { name: "device_id", kind: "string" },
|
||||
10: { name: "shoot_data", kind: "message", type: "MatchShoot" },
|
||||
11: { name: "details", kind: "message", type: "MatchShoot", repeated: true },
|
||||
12: { name: "training_type", kind: "string" },
|
||||
13: { name: "difficulty_level", kind: "int32" },
|
||||
14: { name: "hit_req", kind: "int32" },
|
||||
15: { name: "arrows_left", kind: "int32" },
|
||||
16: { name: "target_arrows", kind: "int32" },
|
||||
17: { name: "target_rings", kind: "int32" },
|
||||
18: { name: "current_arrows", kind: "int32" },
|
||||
19: { name: "current_rings", kind: "int32" },
|
||||
20: { name: "blocks", kind: "int32" },
|
||||
21: { name: "random_block", kind: "int32" },
|
||||
22: { name: "random_ring_area", kind: "int32" },
|
||||
23: { name: "time_limit", kind: "int32" },
|
||||
24: { name: "completed", kind: "bool" },
|
||||
25: { name: "total_arrows", kind: "int32" },
|
||||
26: { name: "duration", kind: "int32" },
|
||||
27: { name: "average_ring", kind: "float" },
|
||||
28: { name: "stability", kind: "float" },
|
||||
29: { name: "max_combo", kind: "int32" },
|
||||
30: { name: "total_hits", kind: "int32" },
|
||||
31: { name: "delta_total_hits", kind: "int32" },
|
||||
32: { name: "delta_duration", kind: "int32" },
|
||||
33: { name: "delta_max_combo", kind: "int32" },
|
||||
34: { name: "delta_total_rings", kind: "int32" },
|
||||
35: { name: "delta_total_arrows", kind: "int32" },
|
||||
36: { name: "delta_average_ring", kind: "float" },
|
||||
37: { name: "delta_stability", kind: "float" },
|
||||
38: { name: "before_exp", kind: "int32" },
|
||||
39: { name: "before_level", kind: "int32" },
|
||||
40: { name: "current_exp", kind: "int32" },
|
||||
41: { name: "level", kind: "int32" },
|
||||
42: { name: "upgrade_exp", kind: "int32" },
|
||||
43: { name: "calories", kind: "double" },
|
||||
},
|
||||
MatchInfo: {
|
||||
1: { name: "match_id", kind: "string" },
|
||||
@@ -233,6 +267,8 @@ function readScalar(reader, kind) {
|
||||
return reader.int64().toString();
|
||||
case "float":
|
||||
return reader.float();
|
||||
case "double":
|
||||
return reader.double();
|
||||
case "bool":
|
||||
return reader.bool();
|
||||
case "string":
|
||||
@@ -355,6 +391,15 @@ export function createHeartbeatAckMessage() {
|
||||
});
|
||||
}
|
||||
|
||||
export function createSyncPracticeInfoMessage({ matchId, userId }) {
|
||||
// 新版个人训练页连接成功后主动请求完整练习信息。
|
||||
return encodeClientMessage({
|
||||
type: ClientMessageType.CLIENT_MSG_SYNC_PRACTICE_INFO,
|
||||
match_id: matchId,
|
||||
user_id: userId,
|
||||
});
|
||||
}
|
||||
|
||||
export function createAckMessage({ matchId, sequence }) {
|
||||
// 普通消息 ACK 仍携带 sequence,但前端不做 sequence 补发或排序。
|
||||
return encodeClientMessage({
|
||||
|
||||
Reference in New Issue
Block a user