3333import java .io .Serializable ;
3434
3535/**
36+ * Meta information
37+ * <p>
3638 * 元信息
3739 *
3840 * @author 渔民小镇
@@ -66,6 +68,11 @@ public final class HeadMetadata implements Serializable {
6668 int cmdMerge ;
6769
6870 /**
71+ * Source logic server client ID
72+ * <p>
73+ * If the request is initiated by an external server,
74+ * this value should be the external server's clientId (a server's unique identifier).
75+ * <p>
6976 * 来源逻辑服 client id
7077 * <pre>
7178 * 比如是对外服发起的请求,这个来源就是对外服的 clientId
@@ -77,6 +84,17 @@ public final class HeadMetadata implements Serializable {
7784 int sourceClientId ;
7885
7986 /**
87+ * Target logic server endPointClientId
88+ * Used to specify which server should process the request
89+ * <p>
90+ * For example, with two chess servers (game logic servers) A and B:
91+ * When players Player1 and Player2 are in a match, if they started playing on Chess Server A,
92+ * then all subsequent requests must be assigned to Chess Server A for processing.
93+ * <p>
94+ * endPointClientId refers to the server's unique identifier.
95+ * <p>
96+ * see {@link com.iohao.game.common.kit.HashKit}
97+ * <p>
8098 * 目标逻辑服 endPointClientId
8199 * <pre>
82100 * 用于指定请求由哪个服务器处理
@@ -108,15 +126,23 @@ public final class HeadMetadata implements Serializable {
108126 byte rpcCommandType ;
109127
110128 /**
111- * 扩展字段
112- * <pre>
113- * 开发者有特殊业务可以通过这个字段来扩展元信息,该字段的信息会跟随每一个请求;
114- * </pre>
129+ * Extended field. Developers can use this field to extend meta-information for special business needs.
130+ * The data in this field will be included with every request.
131+ * <p>
132+ * 扩展字段,开发者有特殊业务可以通过这个字段来扩展元信息,该字段的信息会跟随每一个请求。
115133 */
116134 byte [] attachmentData ;
117135
118136 /**
119- * netty 的 channelId。
137+ * netty channelId
138+ * <p>
139+ * The framework stores Netty's channelId to allow the external server to look up the corresponding connection.
140+ * <p>
141+ * After a player logs in, the framework will use the player's userId to locate the corresponding connection (channel) instead of the channelId,
142+ * because the channelId string is too long, and transmitting this value to the logic server each time would slightly impact performance.
143+ * <p>
144+ * Once the player logs in, the framework will no longer use this property.
145+ * However, if needed, developers can repurpose this field for their own use.
120146 * <pre>
121147 * 框架存放 netty 的 channelId 是为了能在对外服查找到对应的连接。
122148 * 当玩家登录后,框架将会使用玩家的 userId 来查找对应的连接(channel),而不是 channelId ;
@@ -130,39 +156,69 @@ public final class HeadMetadata implements Serializable {
130156 /** 消息标记号;由前端请求时设置,服务器响应时会携带上 */
131157 int msgId ;
132158
133- /** 框架自用字段。将来变化可能较大,开发者请不要使用。 */
159+ /**
160+ * Framework's internal fields. Future changes are likely to be significant, so developers should refrain from using them.
161+ * <p>
162+ * 框架自用字段。将来变化可能较大,开发者请不要使用。
163+ */
134164 int stick ;
135165
136166 /**
167+ * The IDs of multiple game logic servers bound to the player
168+ * <pre>
169+ * All requests related to this game logic server will be routed to the bound game logic server for processing.
170+ * Even if multiple game logic servers of the same type are running, requests will still be directed to the originally bound server.
171+ * </pre>
172+ * <p>
137173 * 玩家绑定的多个游戏逻辑服 id
138174 * <pre>
139175 * 所有与该游戏逻辑服相关的请求都将被分配给已绑定的游戏逻辑服处理。
140176 * 即使启动了多个同类型的游戏逻辑服,该请求仍将被分配给已绑定的游戏逻辑服处理。
141177 * </pre>
142178 */
143179 int [] bindingLogicServerIds ;
144- /** 框架自用字段。将来变化可能较大,开发者请不要使用。 */
180+ /**
181+ * Framework's internal fields. Future changes are likely to be significant, so developers should refrain from using them.
182+ * <p>
183+ * 框架自用字段。将来变化可能较大,开发者请不要使用。
184+ */
145185 int cacheCondition ;
146186 /**
147- * 自定义数据,专为开发者预留的一个字段,开发者可以利用该字段来传递自定义数据
148- * <pre>
149- * 该字段由开发者自己定义,框架不会对数据做任何处理,也不会做任何检查,
150- * 开发者可以利用该字段来传递任何数据,包括自定义对象。
151- * </pre>
187+ * Custom data, a field reserved specifically for developers.
188+ * Developers can use this field to pass custom data.
189+ * The field is entirely user-defined—the framework will neither process nor validate its contents.
190+ * Developers can leverage it to transmit any data, including custom objects.
191+ * <p>
192+ * 自定义数据,专为开发者预留的一个字段,开发者可以利用该字段来传递自定义数据。
193+ * 该字段由开发者自己定义,框架不会对数据做任何处理,也不会做任何检查,开发者可以利用该字段来传递任何数据,包括自定义对象。
152194 */
153195 byte [] customData ;
154- /** 所选执行器 */
155196 ExecutorSelectEnum executorSelect ;
156- /** traceId */
157197 String traceId ;
158- /** 框架自用字段。将来变化可能较大,开发者请不要使用。 */
198+ /**
199+ * Framework's internal fields. Future changes are likely to be significant, so developers should refrain from using them.
200+ * <p>
201+ * 框架自用字段。将来变化可能较大,开发者请不要使用。
202+ */
159203 byte [] userProcessorExecutorSelectorBytes ;
160- /** 临时变量 */
204+ /**
205+ * Temporary variable
206+ * <p>
207+ * 临时变量
208+ */
161209 transient Object other ;
162210 transient int withNo ;
163- /** 请求命令类型: 0 心跳,1 业务 */
211+ /**
212+ * Request command type: 0 Heartbeat, 1 Business
213+ * <p>
214+ * 请求命令类型: 0 心跳,1 业务
215+ */
164216 transient int cmdCode ;
165- /** 协议开关,用于一些协议级别的开关控制,比如 安全加密校验等。 : 0 不校验 */
217+ /**
218+ * Protocol switch: Used for protocol-level control (e.g., security encryption verification). 0: No verification
219+ * <p>
220+ * 协议开关,用于一些协议级别的开关控制,比如 安全加密校验等。 : 0 不校验
221+ */
166222 transient int protocolSwitch ;
167223 /** 预留 inet */
168224 @ Ignore
@@ -176,18 +232,6 @@ public HeadMetadata setCmdInfo(CmdInfo cmdInfo) {
176232 return this ;
177233 }
178234
179- /**
180- * 得到 cmdInfo 命令路由信息
181- * <pre>
182- * 如果只是为了获取 cmd 与 subCmd,下面的方式效率会更高
183- * cmd = CmdKit.getCmd(cmdMerge);
184- * subCmd = CmdKit.getSubCmd(cmdMerge);
185- *
186- * 但实际上更推荐使用 CmdInfo,这样使得代码书写简洁,也更容易理解,毕竟代码是给人看的。
187- * </pre>
188- *
189- * @return cmdInfo
190- */
191235 public CmdInfo getCmdInfo () {
192236 return CmdInfo .of (this .cmdMerge );
193237 }
@@ -198,16 +242,18 @@ public HeadMetadata setCmdMerge(int cmdMerge) {
198242 }
199243
200244 /**
201- * 类似 clone
245+ * Simple clone
202246 * <p>
203- * 使用场景
247+ * Usage scenario ( 使用场景)
204248 * <pre>
205- * 与其他游戏逻辑服通信时可以使用
206- * 方法中给 HeadMetadata 赋值了玩家的必要属性:
249+ * Can be used when communicating with other game logic servers.
250+ * The method assigns necessary player attributes to HeadMetadata.
251+ *
252+ * (与其他游戏逻辑服通信时可以使用,方法中给 HeadMetadata 赋值了玩家的必要属性)
207253 * userId、attachmentData、channelId、bindingLogicServerIds、customData
208254 * traceId、executorSelect
209255 * </pre>
210- * 以下属性不会赋值,如有需要,请自行赋值
256+ * Unassigned by default. Set manually when required. ( 以下属性不会赋值,如有需要,请自行赋值)
211257 * <pre>
212258 * cmdMerge
213259 * sourceClientId
0 commit comments