@xmobitea/gn-typescript-client 2.6.13 → 2.6.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (286) hide show
  1. package/AGENTS.md +37 -0
  2. package/README.MD +420 -1
  3. package/dist/gearn.js.client.js +25056 -1056
  4. package/dist/gearn.js.client.min.js +1 -1
  5. package/dist/index.d.ts +30 -0
  6. package/dist/index.js +24236 -212
  7. package/dist/runtime/GNNetwork.d.ts +687 -3
  8. package/dist/runtime/GNNetworkAuthenticateApi.d.ts +327 -0
  9. package/dist/runtime/GNNetworkCharacterPlayerApi.d.ts +1026 -0
  10. package/dist/runtime/GNNetworkCloudScriptApi.d.ts +141 -0
  11. package/dist/runtime/GNNetworkContentApi.d.ts +243 -0
  12. package/dist/runtime/GNNetworkDashboardApi.d.ts +221 -0
  13. package/dist/runtime/GNNetworkGamePlayerApi.d.ts +1033 -0
  14. package/dist/runtime/GNNetworkGroupApi.d.ts +783 -0
  15. package/dist/runtime/GNNetworkInventoryApi.d.ts +673 -0
  16. package/dist/runtime/GNNetworkMasterPlayerApi.d.ts +1614 -6
  17. package/dist/runtime/GNNetworkMultiplayerApi.d.ts +234 -0
  18. package/dist/runtime/GNNetworkStoreInventoryApi.d.ts +309 -0
  19. package/dist/runtime/common/Action0.d.ts +30 -0
  20. package/dist/runtime/common/Action1.d.ts +32 -0
  21. package/dist/runtime/common/Action2.d.ts +21 -0
  22. package/dist/runtime/common/Action3.d.ts +16 -0
  23. package/dist/runtime/common/Action4.d.ts +17 -0
  24. package/dist/runtime/common/GNData.d.ts +368 -0
  25. package/dist/runtime/config/GNServerSettings.d.ts +442 -12
  26. package/dist/runtime/constant/Commands.d.ts +80 -0
  27. package/dist/runtime/constant/EventCode.d.ts +48 -0
  28. package/dist/runtime/constant/OperationCode.d.ts +74 -1
  29. package/dist/runtime/constant/ReturnCode.d.ts +72 -0
  30. package/dist/runtime/constant/enumType/ExecuteResponseStatus.d.ts +31 -0
  31. package/dist/runtime/constant/enumType/FriendStatus.d.ts +39 -0
  32. package/dist/runtime/constant/enumType/GoogleLoginType.d.ts +23 -0
  33. package/dist/runtime/constant/enumType/GroupStatus.d.ts +32 -0
  34. package/dist/runtime/constant/enumType/InvalidMemberType.d.ts +75 -0
  35. package/dist/runtime/constant/enumType/ItemType.d.ts +23 -0
  36. package/dist/runtime/constant/enumType/MatchStatus.d.ts +30 -0
  37. package/dist/runtime/constant/enumType/MatchmakingMemberStatus.d.ts +24 -0
  38. package/dist/runtime/constant/enumType/MatchmakingTicketStatus.d.ts +34 -0
  39. package/dist/runtime/constant/enumType/OwnerType.d.ts +40 -0
  40. package/dist/runtime/constant/enumType/PermissionDataItem.d.ts +22 -0
  41. package/dist/runtime/constant/enumType/PushPlatformType.d.ts +18 -0
  42. package/dist/runtime/constant/enumType/RequestRole.d.ts +32 -0
  43. package/dist/runtime/constant/enumType/RequestType.d.ts +70 -0
  44. package/dist/runtime/constant/enumType/StoreItemType.d.ts +21 -0
  45. package/dist/runtime/constant/enumType/StoreReceiveType.d.ts +30 -0
  46. package/dist/runtime/constant/errorCode/ErrorCode.d.ts +190 -8
  47. package/dist/runtime/constant/parameterCode/ParameterCode.d.ts +35 -5
  48. package/dist/runtime/entity/DataMember.d.ts +338 -0
  49. package/dist/runtime/entity/GNMetadata.d.ts +101 -0
  50. package/dist/runtime/entity/InvalidMember.d.ts +28 -0
  51. package/dist/runtime/entity/OperationEvent.d.ts +49 -0
  52. package/dist/runtime/entity/OperationRequest.d.ts +108 -0
  53. package/dist/runtime/entity/OperationResponse.d.ts +110 -0
  54. package/dist/runtime/entity/models/AuthenticateModels.d.ts +115 -0
  55. package/dist/runtime/entity/models/AuthenticateRequestModels.d.ts +131 -0
  56. package/dist/runtime/entity/models/AuthenticateResponseModels.d.ts +131 -0
  57. package/dist/runtime/entity/models/CharacterPlayerModels.d.ts +625 -1
  58. package/dist/runtime/entity/models/CharacterPlayerRequestModels.d.ts +972 -0
  59. package/dist/runtime/entity/models/CharacterPlayerResponseModels.d.ts +332 -0
  60. package/dist/runtime/entity/models/CloudScriptModels.d.ts +109 -0
  61. package/dist/runtime/entity/models/CloudScriptRequestModels.d.ts +107 -0
  62. package/dist/runtime/entity/models/CloudScriptResponseModels.d.ts +46 -0
  63. package/dist/runtime/entity/models/ContentModels.d.ts +124 -0
  64. package/dist/runtime/entity/models/ContentRequestModels.d.ts +152 -0
  65. package/dist/runtime/entity/models/ContentResponseModels.d.ts +58 -0
  66. package/dist/runtime/entity/models/DashboardModels.d.ts +371 -8
  67. package/dist/runtime/entity/models/DashboardRequestModels.d.ts +172 -0
  68. package/dist/runtime/entity/models/DashboardResponseModels.d.ts +170 -0
  69. package/dist/runtime/entity/models/GamePlayerModels.d.ts +644 -1
  70. package/dist/runtime/entity/models/GamePlayerRequestModels.d.ts +959 -0
  71. package/dist/runtime/entity/models/GamePlayerResponseModels.d.ts +333 -1
  72. package/dist/runtime/entity/models/GenericModels.d.ts +94 -0
  73. package/dist/runtime/entity/models/GroupModels.d.ts +484 -2
  74. package/dist/runtime/entity/models/GroupRequestModels.d.ts +737 -0
  75. package/dist/runtime/entity/models/GroupResponseModels.d.ts +254 -0
  76. package/dist/runtime/entity/models/InventoryModels.d.ts +415 -0
  77. package/dist/runtime/entity/models/InventoryRequestModels.d.ts +629 -0
  78. package/dist/runtime/entity/models/InventoryResponseModels.d.ts +218 -0
  79. package/dist/runtime/entity/models/MasterPlayerModels.d.ts +1065 -3
  80. package/dist/runtime/entity/models/MasterPlayerRequestModels.d.ts +1560 -6
  81. package/dist/runtime/entity/models/MasterPlayerResponseModels.d.ts +532 -1
  82. package/dist/runtime/entity/models/MultiplayerModels.d.ts +199 -0
  83. package/dist/runtime/entity/models/MultiplayerRequestModels.d.ts +196 -0
  84. package/dist/runtime/entity/models/MultiplayerResponseModels.d.ts +74 -0
  85. package/dist/runtime/entity/models/StoreInventoryModels.d.ts +262 -0
  86. package/dist/runtime/entity/models/StoreInventoryRequestModels.d.ts +268 -0
  87. package/dist/runtime/entity/models/StoreInventoryResponseModels.d.ts +98 -0
  88. package/dist/runtime/entity/request/CustomOperationRequest.d.ts +99 -0
  89. package/dist/runtime/entity/response/CustomOperationResponse.d.ts +118 -0
  90. package/dist/runtime/entity/response/GetAuthInfoResponse.d.ts +53 -0
  91. package/dist/runtime/entity/response/HealthCheckResponse.d.ts +56 -0
  92. package/dist/runtime/entity/response/UploadFileResponse.d.ts +19 -0
  93. package/dist/runtime/helper/CodeHelper.d.ts +122 -0
  94. package/dist/runtime/helper/ConverterService.d.ts +74 -0
  95. package/dist/runtime/helper/EnumUtility.d.ts +63 -0
  96. package/dist/runtime/helper/GNSupport.d.ts +64 -4
  97. package/dist/runtime/helper/GNUtils.d.ts +54 -0
  98. package/dist/runtime/helper/MessagePackConverterService.d.ts +48 -0
  99. package/dist/runtime/helper/OperationHelper.d.ts +51 -0
  100. package/dist/runtime/helper/StorageService.d.ts +48 -8
  101. package/dist/runtime/logger/GNDebug.d.ts +117 -0
  102. package/dist/runtime/networking/AuthenticateStatus.d.ts +64 -0
  103. package/dist/runtime/networking/IPeer.d.ts +83 -0
  104. package/dist/runtime/networking/NetworkingPeer.d.ts +256 -1
  105. package/dist/runtime/networking/OperationPending.d.ts +112 -0
  106. package/dist/runtime/networking/PeerBase.d.ts +231 -0
  107. package/dist/runtime/networking/handler/IServerEventHandler.d.ts +84 -0
  108. package/dist/runtime/networking/handler/OnCharacterPlayerFriendUpdateEventHandler.d.ts +69 -0
  109. package/dist/runtime/networking/handler/OnCharacterPlayerGroupUpdateEventHandler.d.ts +49 -0
  110. package/dist/runtime/networking/handler/OnGamePlayerFriendUpdateEventHandler.d.ts +50 -0
  111. package/dist/runtime/networking/handler/OnGamePlayerGroupUpdateEventHandler.d.ts +41 -0
  112. package/dist/runtime/networking/handler/OnGroupMemberUpdateEventHandler.d.ts +47 -0
  113. package/dist/runtime/networking/handler/OnGroupMessageUpdateEventHandler.d.ts +46 -0
  114. package/dist/runtime/networking/http/HttpPeer.d.ts +173 -0
  115. package/dist/runtime/networking/http/NetworkingHttpPeerBase.d.ts +87 -0
  116. package/dist/runtime/networking/http/NetworkingPeerAxiosRequest.d.ts +113 -0
  117. package/dist/runtime/networking/socket/NetworkingPeerSocketIOClient.d.ts +145 -0
  118. package/dist/runtime/networking/socket/NetworkingSocketPeerBase.d.ts +198 -0
  119. package/dist/runtime/networking/socket/SocketPeer.d.ts +155 -0
  120. package/dist/runtime/typescript/ServiceUpdate.d.ts +46 -0
  121. package/docs/AI_CHEATSHEET.md +211 -0
  122. package/docs/COOKBOOK.md +912 -0
  123. package/docs/RULES.md +307 -0
  124. package/docs/ai-manifest.json +725 -0
  125. package/docs/guides/AUTHENTICATE.md +246 -0
  126. package/docs/guides/CHARACTER_PLAYER.md +439 -0
  127. package/docs/guides/CLOUDSCRIPT.md +335 -0
  128. package/docs/guides/COCOS_CREATOR_INTEGRATION.md +150 -0
  129. package/docs/guides/CONTENT.md +291 -0
  130. package/docs/guides/DASHBOARD.md +262 -0
  131. package/docs/guides/GAME_PLAYER.md +473 -0
  132. package/docs/guides/GROUP.md +412 -0
  133. package/docs/guides/INVENTORY.md +375 -0
  134. package/docs/guides/MASTER_PLAYER.md +458 -0
  135. package/docs/guides/MULTIPLAYER.md +303 -0
  136. package/docs/guides/STORE_INVENTORY.md +313 -0
  137. package/docs/llms-full.txt +43 -0
  138. package/docs/reference/API_AUTHENTICATE.md +75 -0
  139. package/docs/reference/API_CHARACTER_PLAYER.md +226 -0
  140. package/docs/reference/API_CLOUDSCRIPT.md +82 -0
  141. package/docs/reference/API_CONTENT.md +88 -0
  142. package/docs/reference/API_DASHBOARD.md +82 -0
  143. package/docs/reference/API_GAME_PLAYER.md +223 -0
  144. package/docs/reference/API_GROUP.md +187 -0
  145. package/docs/reference/API_INDEX.md +57 -0
  146. package/docs/reference/API_INVENTORY.md +169 -0
  147. package/docs/reference/API_MASTER_PLAYER.md +323 -0
  148. package/docs/reference/API_MULTIPLAYER.md +97 -0
  149. package/docs/reference/API_STORE_INVENTORY.md +109 -0
  150. package/docs/reference/CONFIG.md +107 -0
  151. package/docs/reference/DTO_INDEX.md +2543 -0
  152. package/docs/reference/ENUMS.md +433 -0
  153. package/docs/reference/ERROR_HANDLING.md +159 -0
  154. package/docs/reference/EVENTS.md +188 -0
  155. package/docs/reference/PERMISSION_RULES.md +55 -0
  156. package/docs/reference/dto/AUTHENTICATE.md +619 -0
  157. package/docs/reference/dto/CHARACTER_PLAYER.md +3686 -0
  158. package/docs/reference/dto/CLOUDSCRIPT.md +400 -0
  159. package/docs/reference/dto/CONTENT.md +548 -0
  160. package/docs/reference/dto/DASHBOARD.md +1980 -0
  161. package/docs/reference/dto/GAME_PLAYER.md +3631 -0
  162. package/docs/reference/dto/GENERIC.md +151 -0
  163. package/docs/reference/dto/GROUP.md +2842 -0
  164. package/docs/reference/dto/INVENTORY.md +2385 -0
  165. package/docs/reference/dto/MASTER_PLAYER.md +6024 -0
  166. package/docs/reference/dto/MULTIPLAYER.md +850 -0
  167. package/docs/reference/dto/STORE_INVENTORY.md +1262 -0
  168. package/llms.txt +47 -0
  169. package/package.json +12 -3
  170. package/GNServerSettings.debug.json +0 -21
  171. package/docs/COCOS_CREATOR_INTEGRATION.md +0 -116
  172. package/examples/cocos-creator/GearNExample.ts.txt +0 -176
  173. package/srcSwift/Package.swift +0 -32
  174. package/srcSwift/Sources/GearN/runtime/GNNetwork.swift +0 -530
  175. package/srcSwift/Sources/GearN/runtime/GNNetworkAuthenticateApi.swift +0 -178
  176. package/srcSwift/Sources/GearN/runtime/GNNetworkCharacterPlayerApi.swift +0 -1162
  177. package/srcSwift/Sources/GearN/runtime/GNNetworkCloudScriptApi.swift +0 -154
  178. package/srcSwift/Sources/GearN/runtime/GNNetworkContentApi.swift +0 -208
  179. package/srcSwift/Sources/GearN/runtime/GNNetworkDashboardApi.swift +0 -240
  180. package/srcSwift/Sources/GearN/runtime/GNNetworkGamePlayerApi.swift +0 -1369
  181. package/srcSwift/Sources/GearN/runtime/GNNetworkGroupApi.swift +0 -1100
  182. package/srcSwift/Sources/GearN/runtime/GNNetworkInventoryApi.swift +0 -937
  183. package/srcSwift/Sources/GearN/runtime/GNNetworkMasterPlayerApi.swift +0 -2323
  184. package/srcSwift/Sources/GearN/runtime/GNNetworkMultiplayerApi.swift +0 -298
  185. package/srcSwift/Sources/GearN/runtime/GNNetworkStoreInventoryApi.swift +0 -397
  186. package/srcSwift/Sources/GearN/runtime/common/Action0.swift +0 -3
  187. package/srcSwift/Sources/GearN/runtime/common/Action1.swift +0 -3
  188. package/srcSwift/Sources/GearN/runtime/common/Action2.swift +0 -3
  189. package/srcSwift/Sources/GearN/runtime/common/Action3.swift +0 -3
  190. package/srcSwift/Sources/GearN/runtime/common/Action4.swift +0 -3
  191. package/srcSwift/Sources/GearN/runtime/common/GNArray.swift +0 -204
  192. package/srcSwift/Sources/GearN/runtime/common/GNData.swift +0 -108
  193. package/srcSwift/Sources/GearN/runtime/common/GNHashtable.swift +0 -200
  194. package/srcSwift/Sources/GearN/runtime/config/GNServerSettings.swift +0 -95
  195. package/srcSwift/Sources/GearN/runtime/constant/Commands.swift +0 -28
  196. package/srcSwift/Sources/GearN/runtime/constant/EventCode.swift +0 -10
  197. package/srcSwift/Sources/GearN/runtime/constant/OperationCode.swift +0 -252
  198. package/srcSwift/Sources/GearN/runtime/constant/ReturnCode.swift +0 -19
  199. package/srcSwift/Sources/GearN/runtime/constant/enumType/ExecuteResponseStatus.swift +0 -9
  200. package/srcSwift/Sources/GearN/runtime/constant/enumType/FriendStatus.swift +0 -8
  201. package/srcSwift/Sources/GearN/runtime/constant/enumType/GoogleLoginType.swift +0 -6
  202. package/srcSwift/Sources/GearN/runtime/constant/enumType/GroupStatus.swift +0 -8
  203. package/srcSwift/Sources/GearN/runtime/constant/enumType/InvalidMemberType.swift +0 -19
  204. package/srcSwift/Sources/GearN/runtime/constant/enumType/ItemType.swift +0 -6
  205. package/srcSwift/Sources/GearN/runtime/constant/enumType/MatchmakingMemberStatus.swift +0 -7
  206. package/srcSwift/Sources/GearN/runtime/constant/enumType/MatchmakingTicketStatus.swift +0 -9
  207. package/srcSwift/Sources/GearN/runtime/constant/enumType/OwnerType.swift +0 -10
  208. package/srcSwift/Sources/GearN/runtime/constant/enumType/PermissionDataItem.swift +0 -6
  209. package/srcSwift/Sources/GearN/runtime/constant/enumType/PushPlatformType.swift +0 -6
  210. package/srcSwift/Sources/GearN/runtime/constant/enumType/RequestRole.swift +0 -7
  211. package/srcSwift/Sources/GearN/runtime/constant/enumType/RequestType.swift +0 -16
  212. package/srcSwift/Sources/GearN/runtime/constant/enumType/StoreItemType.swift +0 -6
  213. package/srcSwift/Sources/GearN/runtime/constant/enumType/StoreReceiveType.swift +0 -9
  214. package/srcSwift/Sources/GearN/runtime/constant/errorCode/ErrorCode.swift +0 -58
  215. package/srcSwift/Sources/GearN/runtime/constant/parameterCode/ParameterCode.swift +0 -672
  216. package/srcSwift/Sources/GearN/runtime/entity/DataMember.swift +0 -196
  217. package/srcSwift/Sources/GearN/runtime/entity/GNMetadata.swift +0 -9
  218. package/srcSwift/Sources/GearN/runtime/entity/InvalidMember.swift +0 -11
  219. package/srcSwift/Sources/GearN/runtime/entity/OperationEvent.swift +0 -38
  220. package/srcSwift/Sources/GearN/runtime/entity/OperationHelper.swift +0 -28
  221. package/srcSwift/Sources/GearN/runtime/entity/OperationRequest.swift +0 -62
  222. package/srcSwift/Sources/GearN/runtime/entity/OperationResponse.swift +0 -98
  223. package/srcSwift/Sources/GearN/runtime/entity/models/AuthenticateModels.swift +0 -351
  224. package/srcSwift/Sources/GearN/runtime/entity/models/AuthenticateRequestModels.swift +0 -81
  225. package/srcSwift/Sources/GearN/runtime/entity/models/AuthenticateResponseModels.swift +0 -108
  226. package/srcSwift/Sources/GearN/runtime/entity/models/CharacterPlayerModels.swift +0 -1045
  227. package/srcSwift/Sources/GearN/runtime/entity/models/CharacterPlayerRequestModels.swift +0 -821
  228. package/srcSwift/Sources/GearN/runtime/entity/models/CharacterPlayerResponseModels.swift +0 -588
  229. package/srcSwift/Sources/GearN/runtime/entity/models/CloudScriptModels.swift +0 -187
  230. package/srcSwift/Sources/GearN/runtime/entity/models/CloudScriptRequestModels.swift +0 -84
  231. package/srcSwift/Sources/GearN/runtime/entity/models/CloudScriptResponseModels.swift +0 -59
  232. package/srcSwift/Sources/GearN/runtime/entity/models/ContentModels.swift +0 -195
  233. package/srcSwift/Sources/GearN/runtime/entity/models/ContentRequestModels.swift +0 -116
  234. package/srcSwift/Sources/GearN/runtime/entity/models/ContentResponseModels.swift +0 -81
  235. package/srcSwift/Sources/GearN/runtime/entity/models/DashboardModels.swift +0 -426
  236. package/srcSwift/Sources/GearN/runtime/entity/models/DashboardRequestModels.swift +0 -160
  237. package/srcSwift/Sources/GearN/runtime/entity/models/DashboardResponseModels.swift +0 -82
  238. package/srcSwift/Sources/GearN/runtime/entity/models/GamePlayerModels.swift +0 -1334
  239. package/srcSwift/Sources/GearN/runtime/entity/models/GamePlayerRequestModels.swift +0 -643
  240. package/srcSwift/Sources/GearN/runtime/entity/models/GamePlayerResponseModels.swift +0 -213
  241. package/srcSwift/Sources/GearN/runtime/entity/models/GenericModels.swift +0 -171
  242. package/srcSwift/Sources/GearN/runtime/entity/models/GroupModels.swift +0 -850
  243. package/srcSwift/Sources/GearN/runtime/entity/models/GroupRequestModels.swift +0 -485
  244. package/srcSwift/Sources/GearN/runtime/entity/models/GroupResponseModels.swift +0 -165
  245. package/srcSwift/Sources/GearN/runtime/entity/models/InventoryModels.swift +0 -679
  246. package/srcSwift/Sources/GearN/runtime/entity/models/InventoryRequestModels.swift +0 -413
  247. package/srcSwift/Sources/GearN/runtime/entity/models/InventoryResponseModels.swift +0 -141
  248. package/srcSwift/Sources/GearN/runtime/entity/models/MasterPlayerModels.swift +0 -378
  249. package/srcSwift/Sources/GearN/runtime/entity/models/MasterPlayerRequestModels.swift +0 -147
  250. package/srcSwift/Sources/GearN/runtime/entity/models/MasterPlayerResponseModels.swift +0 -318
  251. package/srcSwift/Sources/GearN/runtime/entity/models/MultiplayerModels.swift +0 -319
  252. package/srcSwift/Sources/GearN/runtime/entity/models/MultiplayerRequestModels.swift +0 -125
  253. package/srcSwift/Sources/GearN/runtime/entity/models/MultiplayerResponseModels.swift +0 -45
  254. package/srcSwift/Sources/GearN/runtime/entity/models/StoreInventoryModels.swift +0 -633
  255. package/srcSwift/Sources/GearN/runtime/entity/models/StoreInventoryRequestModels.swift +0 -173
  256. package/srcSwift/Sources/GearN/runtime/entity/models/StoreInventoryResponseModels.swift +0 -61
  257. package/srcSwift/Sources/GearN/runtime/entity/request/CustomOperationRequest.swift +0 -42
  258. package/srcSwift/Sources/GearN/runtime/entity/response/CustomOperationResponse.swift +0 -49
  259. package/srcSwift/Sources/GearN/runtime/entity/response/GetAuthInfoResponse.swift +0 -43
  260. package/srcSwift/Sources/GearN/runtime/entity/response/HealthCheckResponse.swift +0 -86
  261. package/srcSwift/Sources/GearN/runtime/entity/response/UploadFileResponse.swift +0 -15
  262. package/srcSwift/Sources/GearN/runtime/helper/CodeHelper.swift +0 -107
  263. package/srcSwift/Sources/GearN/runtime/helper/ConverterService.swift +0 -98
  264. package/srcSwift/Sources/GearN/runtime/helper/EnumUtility.swift +0 -34
  265. package/srcSwift/Sources/GearN/runtime/helper/GNSupport.swift +0 -41
  266. package/srcSwift/Sources/GearN/runtime/helper/GNUtils.swift +0 -66
  267. package/srcSwift/Sources/GearN/runtime/helper/MessagePackConverterService.swift +0 -21
  268. package/srcSwift/Sources/GearN/runtime/helper/StorageService.swift +0 -29
  269. package/srcSwift/Sources/GearN/runtime/logger/GNDebug.swift +0 -33
  270. package/srcSwift/Sources/GearN/runtime/networking/AuthenticateStatus.swift +0 -24
  271. package/srcSwift/Sources/GearN/runtime/networking/IPeer.swift +0 -8
  272. package/srcSwift/Sources/GearN/runtime/networking/NetworkingPeer.swift +0 -368
  273. package/srcSwift/Sources/GearN/runtime/networking/OperationPending.swift +0 -81
  274. package/srcSwift/Sources/GearN/runtime/networking/PeerBase.swift +0 -228
  275. package/srcSwift/Sources/GearN/runtime/networking/handler/IServerEventHandler.swift +0 -20
  276. package/srcSwift/Sources/GearN/runtime/networking/http/HttpPeer.swift +0 -226
  277. package/srcSwift/Sources/GearN/runtime/networking/http/HttpTypes.swift +0 -24
  278. package/srcSwift/Sources/GearN/runtime/networking/http/NetworkingHttpPeerBase.swift +0 -13
  279. package/srcSwift/Sources/GearN/runtime/networking/http/NetworkingPeerUrlSession.swift +0 -125
  280. package/srcSwift/Sources/GearN/runtime/networking/request/NetRequest.swift +0 -19
  281. package/srcSwift/Sources/GearN/runtime/networking/response/NetResponse.swift +0 -13
  282. package/srcSwift/Sources/GearN/runtime/networking/socket/NetworkingPeerSocketIOClient.swift +0 -244
  283. package/srcSwift/Sources/GearN/runtime/networking/socket/NetworkingSocketPeerBase.swift +0 -59
  284. package/srcSwift/Sources/GearN/runtime/networking/socket/SocketPeer.swift +0 -136
  285. package/tsconfig-build.cocos.json +0 -31
  286. package/webpack.config.cocos.mjs +0 -78
@@ -4,43 +4,241 @@ import { GNHashtable } from "./../../common/GNData";
4
4
  import { RequestRole } from "./../../constant/enumType/RequestRole";
5
5
  import { RequestType } from "./../../constant/enumType/RequestType";
6
6
  import { OperationRequest } from "./../../entity/OperationRequest";
7
+ /**
8
+ * Inbound socket frame buffered between the transport callback and the
9
+ * SDK service-loop tick.
10
+ *
11
+ * The socket transport receives data on its own callback thread; rather
12
+ * than decoding and dispatching synchronously the raw payload is queued
13
+ * here so that all SDK-visible work happens on the
14
+ * {@link ServiceUpdate} tick, which simplifies error handling and lets
15
+ * the application reason about callback ordering.
16
+ */
7
17
  export declare class SocketPacket {
18
+ /**
19
+ * Raw payload as delivered by the underlying socket.io client —
20
+ * either an `ArrayBuffer` / `Uint8Array` (MsgPack) or a plain
21
+ * decoded object (JSON).
22
+ */
8
23
  obj: any;
24
+ /**
25
+ * `true` when {@link obj} is a MessagePack byte buffer that
26
+ * still needs decoding via {@link MessagePackConverterService},
27
+ * `false` when it is already a plain JS object.
28
+ */
9
29
  isMsgPack: boolean;
30
+ /**
31
+ * @param obj Raw payload from the socket callback.
32
+ * @param isMsgPack Whether the payload is MessagePack-encoded.
33
+ */
10
34
  constructor(obj: any, isMsgPack: boolean);
11
35
  }
36
+ /**
37
+ * Transport-agnostic skeleton shared by every concrete socket
38
+ * implementation.
39
+ *
40
+ * Owns the lifecycle handlers (connect / disconnect callbacks),
41
+ * buffered response / event queues and the JSON / MessagePack decode
42
+ * loop driven by {@link service}. Concrete subclasses such as
43
+ * {@link NetworkingPeerSocketIOClient} only need to:
44
+ * - implement {@link reInitNewSocket} so the underlying socket.io
45
+ * client is created;
46
+ * - override {@link emit} to write outbound frames;
47
+ * - override {@link sendRequestAuthSocket} when their wire protocol
48
+ * requires an explicit auth frame after connect;
49
+ * - push inbound frames into {@link responsePacketLst} /
50
+ * {@link eventPacketLst} from the transport's own callbacks.
51
+ *
52
+ * Decoding policy: every frame is decoded on the SDK service tick
53
+ * inside a try/catch. A decode failure logs through
54
+ * {@link GNDebug.logException} and is swallowed — the SDK does not
55
+ * propagate decode failures to the application because they would
56
+ * almost always be unhandleable noise.
57
+ */
12
58
  export declare abstract class NetworkingSocketPeerBase {
59
+ /** Reconnect backoff in milliseconds (from server settings). */
13
60
  protected reconnectDelay: number;
61
+ /** Heartbeat interval in milliseconds. */
14
62
  protected pingInterval: number;
63
+ /** Heartbeat timeout in milliseconds. */
15
64
  protected pingTimeout: number;
65
+ /** socket.io session id; empty string when disconnected. */
16
66
  clientId: string;
67
+ /**
68
+ * Current connection state mirror. Maintained by the concrete
69
+ * subclass — true between `connect` and `disconnect`.
70
+ */
17
71
  isWsConnected: boolean;
72
+ /**
73
+ * Inbound response frames queued for decoding on the next
74
+ * service tick. Concrete subclasses push raw frames here from
75
+ * the socket callbacks; {@link service} drains the queue.
76
+ */
18
77
  protected responsePacketLst: SocketPacket[];
78
+ /** Inbound event frames queued for decoding on the next service tick. */
19
79
  protected eventPacketLst: SocketPacket[];
80
+ /** Absolute base URL handed to the underlying socket.io client. */
20
81
  protected url: string;
82
+ /** Callback receiving decoded events. */
21
83
  private _onEventHandler;
84
+ /** Callback receiving decoded responses. */
22
85
  private _onResponseHandler;
86
+ /**
87
+ * One-shot connect callback handed in via {@link connect}. Cleared
88
+ * after firing once so that the next reconnect does not re-fire
89
+ * the same callback.
90
+ */
23
91
  private _onSocketConnect;
92
+ /** One-shot disconnect callback handed in via {@link close}. */
24
93
  private _onSocketDisconnect;
94
+ /** Multi-subscriber list of connect callbacks. */
25
95
  private _onConnectHandler;
96
+ /** Multi-subscriber list of disconnect callbacks. */
26
97
  private _onDisconnectHandler;
27
98
  constructor();
99
+ /**
100
+ * Stores socket configuration and resets the inbound buffers.
101
+ *
102
+ * Called by {@link SocketPeer.initGNSocketObject} just before
103
+ * {@link reInitNewSocket} builds the underlying socket.io client.
104
+ *
105
+ * @param url Absolute base URL produced by
106
+ * {@link GNServerSettings.getSocketUrl}.
107
+ * @param reconnectDelay Reconnect backoff in milliseconds.
108
+ * @param pingInterval Heartbeat interval in milliseconds.
109
+ * @param pingTimeout Heartbeat timeout in milliseconds.
110
+ */
28
111
  init(url: string, reconnectDelay: number, pingInterval: number, pingTimeout: number): void;
112
+ /**
113
+ * Captures a one-shot connect callback. The concrete subclass is
114
+ * expected to dial the socket and call {@link onConnectHandler}
115
+ * once the underlying client reports `connect`.
116
+ *
117
+ * @param _onSocketConnect Optional callback. Pass `null` to skip
118
+ * the one-shot notification while still
119
+ * opening the socket.
120
+ */
29
121
  connect(_onSocketConnect: Action0): void;
122
+ /**
123
+ * Captures a one-shot disconnect callback. The concrete subclass
124
+ * is expected to tear down the socket and call
125
+ * {@link onDisconnectHandler}.
126
+ */
30
127
  close(_onSocketDisconnect: Action0): void;
128
+ /**
129
+ * Sends an explicit auth frame so the backend can associate the
130
+ * socket session with a user.
131
+ *
132
+ * Default implementation is a no-op — concrete subclasses such as
133
+ * {@link NetworkingPeerSocketIOClient} override this with the
134
+ * wire-format-specific frame.
135
+ */
31
136
  sendRequestAuthSocket(): void;
137
+ /**
138
+ * Public send entry point. Forwards the frame to {@link emit};
139
+ * exists as a hook for future cross-cutting behaviour
140
+ * (compression, telemetry).
141
+ */
32
142
  send(requestType: RequestType, role: RequestRole, operationRequest: OperationRequest, authToken: string, secretKey: string, customTags: GNHashtable, gameId: string): void;
143
+ /**
144
+ * Subclass hook that performs the actual socket emit.
145
+ *
146
+ * Override on each concrete socket implementation. The default
147
+ * no-op exists so the abstract class can still be instantiated
148
+ * during partial implementations / mocking in tests.
149
+ */
33
150
  protected emit(requestType: RequestType, role: RequestRole, operationRequest: OperationRequest, authToken: string, secretKey: string, customTags: GNHashtable, gameId: string): void;
151
+ /**
152
+ * Subclass hook for (re)building the underlying socket.io client.
153
+ *
154
+ * Called once from {@link SocketPeer.initGNSocketObject} during
155
+ * SDK startup. The default no-op exists so the abstract class
156
+ * still works in tests; production code uses
157
+ * {@link NetworkingPeerSocketIOClient.reInitNewSocket}.
158
+ */
34
159
  reInitNewSocket(): void;
160
+ /**
161
+ * Adds a callback to the multi-subscriber connect channel.
162
+ *
163
+ * Use a stable function reference so the matching
164
+ * {@link removeOnConnectHandler} can find and remove it.
165
+ */
35
166
  setOnConnectHandler(_onConnectHandler: Action0): void;
167
+ /**
168
+ * Adds a callback to the multi-subscriber disconnect channel.
169
+ */
36
170
  setOnDisconnectHandler(_onDisconnectHandler: Action0): void;
171
+ /**
172
+ * Removes a previously registered connect callback. No-op when
173
+ * the function reference is not currently subscribed.
174
+ */
37
175
  removeOnConnectHandler(_onConnectHandler: Action0): void;
176
+ /**
177
+ * Removes a previously registered disconnect callback.
178
+ */
38
179
  removeOnDisconnectHandler(_onDisconnectHandler: Action0): void;
180
+ /**
181
+ * Concrete subclasses call this after the underlying transport
182
+ * reports `connect`.
183
+ *
184
+ * Sequence:
185
+ * 1. Fan out to every subscriber registered through
186
+ * {@link setOnConnectHandler}.
187
+ * 2. When a cached auth token exists, send the auth frame so the
188
+ * backend can associate the new session with the user without
189
+ * waiting for the next request.
190
+ * 3. Resolve the one-shot {@link _onSocketConnect} callback and
191
+ * clear it so the next reconnect starts fresh.
192
+ */
39
193
  onConnectHandler(): void;
194
+ /**
195
+ * Concrete subclasses call this after the underlying transport
196
+ * reports `disconnect`.
197
+ *
198
+ * Fans out to every subscriber on the disconnect channel and
199
+ * resolves the one-shot {@link _onSocketDisconnect} callback.
200
+ */
40
201
  onDisconnectHandler(): void;
202
+ /**
203
+ * Replaces the single-slot raw event callback used by the SDK.
204
+ *
205
+ * The SDK installs its own dispatch routine through this slot
206
+ * during {@link SocketPeer.initGNSocketObject}; application code
207
+ * uses {@link GNNetwork.setOnEventHandler} for the
208
+ * higher-level typed event channel instead.
209
+ */
41
210
  setOnEventHandler(_onEventHandler: Action1<GNHashtable>): void;
211
+ /**
212
+ * Routes a decoded event to the registered handler. Skipped
213
+ * silently when no handler is set.
214
+ */
42
215
  onEventHandler(obj: GNHashtable): void;
216
+ /**
217
+ * Replaces the single-slot raw response callback used by the SDK.
218
+ *
219
+ * Bound during {@link SocketPeer.initGNSocketObject} to the
220
+ * shared {@link PeerBase.onResponseHandler} machinery.
221
+ */
43
222
  setOnResponseHandler(_onResponseHandler: Action1<GNHashtable>): void;
223
+ /**
224
+ * Routes a decoded response to the registered handler.
225
+ */
44
226
  onResponseHandler(obj: GNHashtable): void;
227
+ /**
228
+ * Drains the inbound response and event buffers on the current
229
+ * service tick.
230
+ *
231
+ * For each queued packet the helper:
232
+ * - decodes the raw payload (MsgPack via
233
+ * {@link MessagePackConverterService.deserialize}, or pass
234
+ * through for JSON);
235
+ * - wraps the result in a {@link GNHashtable};
236
+ * - dispatches to the matching response / event handler.
237
+ *
238
+ * Decode failures are logged via
239
+ * {@link GNDebug.logException} and swallowed so a malformed frame
240
+ * cannot stall the service loop. After processing each list is
241
+ * truncated to length 0 (cheaper than allocating a fresh array).
242
+ */
45
243
  service(): void;
46
244
  }
@@ -5,25 +5,180 @@ import { OperationEvent } from "./../../entity/OperationEvent";
5
5
  import { IServerEventHandler } from "./../handler/IServerEventHandler";
6
6
  import { OperationPending } from "./../OperationPending";
7
7
  import { PeerBase } from "./../PeerBase";
8
+ /**
9
+ * High-level socket peer used by {@link NetworkingPeer} and ultimately
10
+ * by {@link GNNetwork}.
11
+ *
12
+ * Bridges the queue / timeout machinery in {@link PeerBase} with the
13
+ * socket-specific transport in {@link NetworkingSocketPeerBase} (the
14
+ * concrete client today is {@link NetworkingPeerSocketIOClient}).
15
+ *
16
+ * Responsibilities:
17
+ * - Build and configure the underlying socket.io client during
18
+ * {@link initGNSocketObject}, then mirror the response / event
19
+ * callbacks back into this class.
20
+ * - Maintain a per-event-code dispatch table populated from every
21
+ * class registered through `@IServerEventHandler.registerEvent`,
22
+ * plus a runtime-add path via {@link subscriberAServerEventHandler}.
23
+ * - Forward connect / disconnect / event subscriptions to the
24
+ * transport.
25
+ * - Override {@link send} to log the outbound frame and apply the
26
+ * default timeout fallback before delegating to the transport.
27
+ */
8
28
  export declare class SocketPeer extends PeerBase {
29
+ /** Concrete low-level socket.io client. */
9
30
  private networkingSocketPeerBase;
31
+ /**
32
+ * Per-event-code dispatch table. Each entry is the ordered list
33
+ * of handler instances that registered against the matching
34
+ * event code.
35
+ */
10
36
  private serverEventHandlersDict;
37
+ /**
38
+ * Single-slot raw observer that receives every decoded event.
39
+ * Replaced through {@link setOnEventHandler}; coexists with the
40
+ * typed dispatch table.
41
+ */
11
42
  private _onEventHandler;
43
+ /**
44
+ * Returns the socket.io session id assigned at connect time, or
45
+ * an empty string when disconnected.
46
+ */
12
47
  getClientId(): string;
48
+ /**
49
+ * Returns whether the underlying socket.io client is in the
50
+ * connected state.
51
+ */
13
52
  isConnected(): boolean;
53
+ /**
54
+ * Pushes the cached auth token through the socket auth frame.
55
+ * Delegates to the transport implementation.
56
+ */
14
57
  sendRequestAuthSocket(): void;
58
+ /**
59
+ * Walks every constructor registered through
60
+ * {@link IServerEventHandler.registerEvent} and instantiates one
61
+ * handler instance per registered class.
62
+ *
63
+ * Why one per class: the registry stores **classes** to keep the
64
+ * decorator API ergonomic; `SocketPeer` materialises one instance
65
+ * per class on init so each handler can hold its own state if
66
+ * needed. Multiple registrations against the same event code are
67
+ * preserved — they are dispatched in registration order.
68
+ */
15
69
  private subscriberServerEventHandler;
70
+ /**
71
+ * Adds a runtime-built handler instance to the dispatch table.
72
+ *
73
+ * Used by {@link GNNetwork.subscriberServerEventHandler} when an
74
+ * application registers a handler that does not use the
75
+ * decorator-based registry.
76
+ */
16
77
  subscriberAServerEventHandler(serverEventHandler: IServerEventHandler): void;
78
+ /**
79
+ * Builds the underlying socket.io client and wires the
80
+ * response / event callbacks back into this class.
81
+ *
82
+ * Lifecycle:
83
+ * 1. Validate the global server settings.
84
+ * 2. Capture the `useSocket` flag into {@link isUse} so the queue
85
+ * short-circuits when the socket transport is disabled.
86
+ * 3. Instantiate {@link NetworkingPeerSocketIOClient} and call
87
+ * `init` + `reInitNewSocket` so the underlying client is
88
+ * fully configured.
89
+ * 4. Bind the transport's response / event callbacks to
90
+ * {@link onResponseHandler} (inherited from
91
+ * {@link PeerBase}) and {@link onEventHandler} on this
92
+ * class.
93
+ * 5. Materialise every decorator-registered server event handler
94
+ * via {@link subscriberServerEventHandler}.
95
+ *
96
+ * @throws Error when the global server settings are missing.
97
+ */
17
98
  initGNSocketObject(): void;
99
+ /**
100
+ * Forwards a connect callback to the underlying transport's
101
+ * multi-subscriber list. See
102
+ * {@link GNNetwork.subscriberOnConnectHandler}.
103
+ */
18
104
  setOnConnectHandler(_onConnectHandler: Action0): void;
105
+ /**
106
+ * Forwards a disconnect callback to the underlying transport's
107
+ * multi-subscriber list. See
108
+ * {@link GNNetwork.subscriberOnDisconnectHandler}.
109
+ */
19
110
  setOnDisconnectHandler(_onDisconnectHandler: Action0): void;
111
+ /**
112
+ * Removes a connect callback from the underlying transport.
113
+ * No-op when the reference is not currently subscribed.
114
+ */
20
115
  removeOnConnectHandler(_onConnectHandler: Action0): void;
116
+ /**
117
+ * Removes a disconnect callback from the underlying transport.
118
+ * No-op when the reference is not currently subscribed.
119
+ */
21
120
  removeOnDisconnectHandler(_onDisconnectHandler: Action0): void;
121
+ /**
122
+ * Opens the underlying socket connection. The optional callback
123
+ * is fired once after the next successful connect.
124
+ */
22
125
  connect(_onSocketConnect: Action0): void;
126
+ /**
127
+ * Closes the underlying socket connection. The optional callback
128
+ * is fired once after the next observed disconnect.
129
+ */
23
130
  disconnect(_onSocketDisconnect: Action0): void;
131
+ /**
132
+ * Replaces the single-slot raw event observer. This is the
133
+ * callback {@link GNNetwork.setOnEventHandler} ultimately writes
134
+ * into.
135
+ */
24
136
  setOnEventHandler(_onEventHandler: Action1<OperationEvent>): void;
137
+ /**
138
+ * Sends a queued operation through the underlying transport.
139
+ *
140
+ * Substitutes the SDK-wide
141
+ * {@link OperationRequest.defaultTimeOut} sentinel with the
142
+ * configured `defaultTimeoutInSeconds` so the timeout sweep on
143
+ * {@link PeerBase.service} uses the real value rather than the
144
+ * sentinel. Then chains into `super.send(...)` so the in-flight
145
+ * map records the request id, logs the outbound frame, and
146
+ * finally delegates to
147
+ * {@link NetworkingSocketPeerBase.send}.
148
+ */
25
149
  send(operationPending: OperationPending): void;
150
+ /**
151
+ * Logs a diagnostic line whenever the queue accepts a new
152
+ * pending entry. The actual queueing is performed by
153
+ * {@link PeerBase.enqueue}; this override only adds telemetry.
154
+ */
26
155
  protected onEnqueue(operationPending: OperationPending): void;
156
+ /**
157
+ * Decodes a raw event payload, fans it out to subscribers and
158
+ * logs the dispatch.
159
+ *
160
+ * Steps:
161
+ * 1. Read `EventCode` and the `Parameters` sub-table from the
162
+ * raw frame, producing a typed {@link OperationEvent}.
163
+ * 2. Log a `[GN Socket EVENT]` diagnostic line.
164
+ * 3. Invoke the single-slot raw observer when registered.
165
+ * 4. Look up the typed handler list for the event code and
166
+ * invoke each registered handler in order.
167
+ *
168
+ * Unrecognised event codes (no handler registered) are silently
169
+ * dropped after the raw-observer call.
170
+ */
27
171
  onEventHandler(obj: GNHashtable): void;
172
+ /**
173
+ * Drives one tick of the peer.
174
+ *
175
+ * Order matters:
176
+ * 1. {@link PeerBase.service} runs first so timeouts are swept
177
+ * and at most one queued request is dispatched.
178
+ * 2. The transport's own service hook drains any inbound packet
179
+ * buffers (response + event). This split ensures the SDK
180
+ * response handler sees responses for requests it just
181
+ * dispatched on the same tick.
182
+ */
28
183
  service(): void;
29
184
  }
@@ -1,8 +1,54 @@
1
1
  import { NetworkingPeer } from "./../networking/NetworkingPeer";
2
+ /**
3
+ * Fixed-rate driver loop that ticks the shared {@link NetworkingPeer}.
4
+ *
5
+ * The SDK has no event loop of its own — every transport relies on
6
+ * a periodic `service()` call to drain queued requests, sweep
7
+ * timeouts, and decode buffered inbound packets. This class wires a
8
+ * `setInterval` to that `service()` method so the work happens
9
+ * automatically on the host runtime's timer.
10
+ *
11
+ * Lifecycle:
12
+ * - {@link GNNetwork.initGNSocketObject} constructs one instance,
13
+ * binds {@link peer}, and calls {@link run}.
14
+ * - The interval fires every 50 ms (20 Hz). The cadence is
15
+ * intentionally faster than the configured `sendRate` so the
16
+ * queue stays responsive when the rate cap allows multiple
17
+ * sends per second.
18
+ * - {@link stop} can be used in tests to halt the loop without
19
+ * tearing down the peer; production code never calls it.
20
+ */
2
21
  export declare class ServiceUpdate {
22
+ /**
23
+ * Active interval handle. `null` when the loop is stopped.
24
+ */
3
25
  private intervalId;
26
+ /**
27
+ * Bound peer to service on every tick. Set by the caller before
28
+ * {@link run} is invoked.
29
+ */
4
30
  peer: NetworkingPeer;
31
+ /**
32
+ * Starts the 50 ms service loop. Idempotent — calling `run`
33
+ * while a loop is already active is a no-op so the SDK
34
+ * bootstrap path can be defensive without leaking timers.
35
+ */
5
36
  run(): void;
37
+ /**
38
+ * Stops the service loop and clears the interval handle.
39
+ *
40
+ * Mainly useful in test setups that want to control SDK
41
+ * timing manually. The SDK itself does not call this — the
42
+ * loop is intended to run for the lifetime of the JS realm.
43
+ */
6
44
  stop(): void;
45
+ /**
46
+ * Per-tick callback. Defers everything to
47
+ * {@link NetworkingPeer.service}, which in turn ticks both
48
+ * transports.
49
+ *
50
+ * Skips silently when {@link peer} is unbound so a partially
51
+ * constructed `ServiceUpdate` cannot crash the timer.
52
+ */
7
53
  private update;
8
54
  }
@@ -0,0 +1,211 @@
1
+ # AI Cheatsheet
2
+
3
+ One-page reference cho AI agent / code assistant. Đọc file này trước, đào sâu khi cần.
4
+
5
+ > Package: `@xmobitea/gn-typescript-client` · Entry point: `GNNetwork` (static class) · Stack: HTTP + WebSocket realtime.
6
+
7
+ ---
8
+
9
+ ## 1. Mandatory pattern (sao chép & dùng)
10
+
11
+ ```ts
12
+ import { GNNetwork, GNServerSettings, ReturnCode, ErrorCode, MessageType, LogType } from "@xmobitea/gn-typescript-client";
13
+
14
+ const settings = new GNServerSettings();
15
+ settings.config({
16
+ serverAddress: "api.example.com",
17
+ serverPort: 443,
18
+ serverSocketPort: 443,
19
+ useSsl: true,
20
+ useSocket: true,
21
+ useHttp: true,
22
+ defaultTimeoutInSeconds: 20,
23
+ messageType: MessageType.MsgPack,
24
+ sendRate: 20,
25
+ reconnectDelay: 5000,
26
+ pingInterval: 20000,
27
+ pingTimeout: 20000,
28
+ secretKey: "<secret-key>",
29
+ gameId: "<game-id>",
30
+ logType: LogType.Error,
31
+ });
32
+
33
+ // Bootstrap — gọi 1 lần, idempotent
34
+ GNNetwork.init(settings);
35
+
36
+ // Mọi call: 2-tier check
37
+ const res = await GNNetwork.<group>.<method>Async(req);
38
+ if (res.returnCode !== ReturnCode.Ok) return; // transport / permission
39
+ if (res.errorCode !== ErrorCode.Ok) return; // business
40
+ useResult(res.responseData);
41
+ ```
42
+
43
+ `Ok === 1` ở **cả** `ReturnCode` và `ErrorCode`. **KHÔNG** giả định `Ok === 0`.
44
+
45
+ ---
46
+
47
+ ## 2. Decision tree: tôi cần làm gì?
48
+
49
+ | Tôi muốn... | Mở file |
50
+ |---|---|
51
+ | Login / register / refresh token | [guides/AUTHENTICATE.md](guides/AUTHENTICATE.md) · [reference/API_AUTHENTICATE.md](reference/API_AUTHENTICATE.md) |
52
+ | MasterPlayer account chung nhiều game: identity, external link/unlink, profile, statistics, currencies, player data, email/push, segment/tag/ban | [guides/MASTER_PLAYER.md](guides/MASTER_PLAYER.md) · [reference/API_MASTER_PLAYER.md](reference/API_MASTER_PLAYER.md) |
53
+ | GamePlayer account theo game environment (`dev`/`live` hoặc custom): profile, friends, groups, inventory owner, online status, statistics/currencies/data | [guides/GAME_PLAYER.md](guides/GAME_PLAYER.md) · [reference/API_GAME_PLAYER.md](reference/API_GAME_PLAYER.md) |
54
+ | CharacterPlayer nhân vật thuộc GamePlayer: profile riêng, statistics/currencies/data, friends/groups/inventory owner theo character | [guides/CHARACTER_PLAYER.md](guides/CHARACTER_PLAYER.md) · [reference/API_CHARACTER_PLAYER.md](reference/API_CHARACTER_PLAYER.md) |
55
+ | Inventory item: query, owner, amount, statistics | [guides/INVENTORY.md](guides/INVENTORY.md) · [reference/API_INVENTORY.md](reference/API_INVENTORY.md) |
56
+ | Group metadata, member, message, group inventory | [guides/GROUP.md](guides/GROUP.md) · [reference/API_GROUP.md](reference/API_GROUP.md) |
57
+ | Store catalog, buy, present, validate receipt | [guides/STORE_INVENTORY.md](guides/STORE_INVENTORY.md) · [reference/API_STORE_INVENTORY.md](reference/API_STORE_INVENTORY.md) |
58
+ | Matchmaking ticket / queue / match query | [guides/MULTIPLAYER.md](guides/MULTIPLAYER.md) · [reference/API_MULTIPLAYER.md](reference/API_MULTIPLAYER.md) |
59
+ | Content config + upload/download file metadata | [guides/CONTENT.md](guides/CONTENT.md) · [reference/API_CONTENT.md](reference/API_CONTENT.md) |
60
+ | CloudScript: publish version, execute function | [guides/CLOUDSCRIPT.md](guides/CLOUDSCRIPT.md) · [reference/API_CLOUDSCRIPT.md](reference/API_CLOUDSCRIPT.md) |
61
+ | Admin login, secret/maintenance/analytics | [guides/DASHBOARD.md](guides/DASHBOARD.md) · [reference/API_DASHBOARD.md](reference/API_DASHBOARD.md) |
62
+ | Realtime event (friend, group, message) | [reference/EVENTS.md](reference/EVENTS.md) |
63
+ | Tra DTO field theo class | [reference/DTO_INDEX.md](reference/DTO_INDEX.md) (grep) hoặc [reference/dto/](reference/dto/) |
64
+ | Enum value numeric | [reference/ENUMS.md](reference/ENUMS.md) |
65
+ | Config field của `GNServerSettings` | [reference/CONFIG.md](reference/CONFIG.md) |
66
+ | Permission flag / `OperationNotAllow` | [reference/PERMISSION_RULES.md](reference/PERMISSION_RULES.md) · [RULES.md § 6](RULES.md#6-permission-flags) |
67
+ | Cách check error / retry / debug | [reference/ERROR_HANDLING.md](reference/ERROR_HANDLING.md) |
68
+ | Scenario end-to-end (16 case) | [COOKBOOK.md](COOKBOOK.md) |
69
+ | Rule chung (route, permission, self/other-self, socket) | [RULES.md](RULES.md) |
70
+ | Machine-readable manifest cho tooling | [ai-manifest.json](ai-manifest.json) |
71
+
72
+ ---
73
+
74
+ ## Glossary bắt buộc
75
+
76
+ | Thuật ngữ | Nghĩa |
77
+ |---|---|
78
+ | `route` | Trust boundary của caller: client, server, hoặc admin. |
79
+ | `self` | Target thuộc user đang authenticate. |
80
+ | `other-self` | Target không thuộc user đang authenticate nhưng vẫn gọi qua route client. |
81
+ | `otherSelfEnable` | Tên permission flag trong backend config. Dùng spelling này trong code/docs. |
82
+ | `secretKey` | Key cấu hình permission per operation. Sai/thiếu secret trả `SecretInvalid`; secret đúng nhưng thiếu flag trả `OperationNotAllow`. |
83
+
84
+ ---
85
+
86
+ ## 3. Route decision (1 phút)
87
+
88
+ Route = **trust boundary của caller**, KHÔNG phải target ownership.
89
+
90
+ ```
91
+ Code chạy ở đâu?
92
+ ├─ App / browser của player → GNNetwork.<group> (Client)
93
+ ├─ Trusted backend (game server, → GNNetwork.<group>.server (Server)
94
+ │ worker, webhook, internal svc)
95
+ └─ Backoffice / GM tool / dashboard → GNNetwork.<group>.admin (Admin)
96
+
97
+ Ngoại lệ: DashboardApi public wrapper vẫn đi RequestRole.Client; backend resolve admin từ authToken sau loginByAdminAccountAsync.
98
+ ```
99
+
100
+ `self / other-self` chỉ áp dụng trên route `client`:
101
+ - `MasterPlayer` / `GamePlayer`: `self` = `userId` trong request trùng `userId` đã authenticate (hoặc bỏ trống).
102
+ - `CharacterPlayer` / `Inventory` / `Group`: `self` = entity thuộc ownership của user đang authenticate.
103
+ - `Content` / `StoreInventory` / `Multiplayer` / `CloudScript`: không có ownership rõ ràng — không ép self/other-self.
104
+
105
+ ---
106
+
107
+ ## 4. Method signature mọi API
108
+
109
+ ```ts
110
+ // Callback form
111
+ GNNetwork.<group>.<method>(requestData, onResponse?, overrideAuthToken?, overrideSecretKey?, customTags?, timeout?);
112
+
113
+ // Async form (preferred)
114
+ const res = await GNNetwork.<group>.<method>Async(requestData, overrideAuthToken?, overrideSecretKey?, customTags?, timeout?);
115
+ ```
116
+
117
+ | Param | Khi nào cần |
118
+ |---|---|
119
+ | `overrideAuthToken` | Impersonate / multi-session / admin gọi trên user khác |
120
+ | `overrideSecretKey` | Override secret cho 1 request, ví dụ tool migration |
121
+ | `customTags` | Trace id, build version, A/B tag — backend có thể log/route |
122
+ | `timeout` | Override default per-request (giây) |
123
+
124
+ Trong code copy-paste, build `requestData` bằng DTO class public:
125
+
126
+ ```ts
127
+ const request = new <Group>Models.<Method>RequestData();
128
+ request.someField = value;
129
+ const res = await GNNetwork.<group>.<method>Async(request);
130
+ ```
131
+
132
+ Không dùng object literal rồi cast sang `RequestData`. Chi tiết: [RULES.md § 8.1](RULES.md#81-build-request-dto-trong-code-copy-paste).
133
+
134
+ Response field public (KHÔNG phải getter): `returnCode`, `errorCode`, `invalidMembers`, `debugMessage`, `responseData`.
135
+
136
+ ---
137
+
138
+ ## 5. Socket flow
139
+
140
+ ```
141
+ 1. Login HTTP (authenticate.loginByXxxAsync) — SDK cache authToken vào StorageService
142
+ 2. GNNetwork.connectSocket() — SDK auto-auth socket nếu authToken đã có
143
+ 3. (chỉ khi socket connect TRƯỚC token, hoặc token vừa đổi)
144
+ GNNetwork.sendRequestAuthSocket() — re-auth thủ công, không reconnect
145
+ ```
146
+
147
+ Hook trước khi connect:
148
+
149
+ ```ts
150
+ GNNetwork.subscriberOnConnectHandler(() => { /* socket up */ });
151
+ GNNetwork.subscriberOnDisconnectHandler(() => { /* socket down */ });
152
+ GNNetwork.setOnEventHandler((event) => { /* raw event */ });
153
+
154
+ // Realtime handler — gán static field; cleanup bằng no-op hoặc wrapper dispatcher
155
+ OnGroupMessageUpdateEventHandler.onUpdate = (payload) => { ... };
156
+ OnGroupMessageUpdateEventHandler.onUpdate = () => {};
157
+ ```
158
+
159
+ Realtime KHÔNG tự chạy chỉ vì đã gọi HTTP (friend/group/...). Phải subscribe handler liệt kê trong [reference/EVENTS.md](reference/EVENTS.md).
160
+
161
+ ---
162
+
163
+ ## 6. Top 5 pitfalls (phải tránh)
164
+
165
+ 1. **Tưởng success là `0`** → `Ok === 1` cả 2 tầng.
166
+ 2. **Skip tầng `returnCode`, đọc thẳng `errorCode`** → khi `returnCode !== Ok`, `errorCode` + `responseData` không đáng tin.
167
+ 3. **Dùng getter `res.getReturnCode()`** → typed response dùng PUBLIC FIELDS.
168
+ 4. **Dùng `.server` / `.admin` từ frontend để vượt permission** → trust boundary leak.
169
+ 5. **`OperationNotAllow` = thiếu secret** → SAI. Secret hợp lệ nhưng permission rule cấm. Check route + flag.
170
+
171
+ 18 anti-patterns đầy đủ + cột "Triệu chứng / Fix": [RULES.md § 10](RULES.md#10-anti-patterns--pitfalls).
172
+
173
+ ---
174
+
175
+ ## 7. Diagnose `ReturnCode` (nhanh)
176
+
177
+ | Code | Nghĩa | Fix |
178
+ |---|---|---|
179
+ | `Ok` | Sang tầng `errorCode` | — |
180
+ | `OperationTimeout` | Network/backend chậm | Retry với backoff nếu idempotent |
181
+ | `OperationNotAllow` | Permission rule cấm | Check route + permission flag (KHÔNG retry) |
182
+ | `InternalServerError` | Backend exception | Báo ops, có thể retry 1 lần |
183
+ | `OperationInvalid` | Operation không tồn tại với role hiện tại | Đang gọi sai namespace, sai `RequestType`/`RequestRole` |
184
+ | `InvalidRequestParameters` | Field invalid | Đọc `res.invalidMembers` để biết field nào |
185
+ | `OperationNotAuthorized` | Không auth với target | Check `authToken` còn hợp lệ |
186
+ | `MaxCCUReject` | Vượt CCU limit | Backoff retry |
187
+ | `MaxRequestReject` | Rate limit | Exponential backoff |
188
+ | `MaxSizeRequestReject` | Payload quá to | Paginate / split |
189
+ | `SecretInvalid` | Secret sai/thiếu/không khớp game | Fix `GNServerSettings` (KHÔNG retry) |
190
+
191
+ So sánh bằng enum symbol, không hardcode số. Giá trị numeric: [reference/ENUMS.md](reference/ENUMS.md). Full table + `ErrorCode`: [reference/ERROR_HANDLING.md](reference/ERROR_HANDLING.md).
192
+
193
+ Gặp `OperationNotAllow` — decision tree + code fallback: [COOKBOOK Scenario 16](COOKBOOK.md#scenario-16-diagnose-operationnotallow). Mapping route → flag cần: [RULES § 6.1](RULES.md#61-mapping-route-target--required-flag).
194
+
195
+ ---
196
+
197
+ ## 8. Khi nào ĐƯỢC đọc `src/`
198
+
199
+ - Đang sửa chính SDK
200
+ - Verify behavior nội bộ chưa được docs cover
201
+ - Tích hợp package: **chỉ** dùng `AGENTS.md + docs + dist/*.d.ts`. Không bám `src/` cho integration code.
202
+
203
+ ---
204
+
205
+ ## 9. Liên kết quan trọng
206
+
207
+ - Single-source-of-truth rules: [RULES.md](RULES.md)
208
+ - AI entry guide chi tiết: [../AGENTS.md](../AGENTS.md)
209
+ - Machine manifest: [ai-manifest.json](ai-manifest.json)
210
+ - Concatenated bundle (optional, generated artifact): [llms-full.txt](llms-full.txt). Không dùng file này làm nguồn thắng khi nó mâu thuẫn với source docs.
211
+ - llmstxt.org index: [../llms.txt](../llms.txt)