@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
@@ -0,0 +1,335 @@
1
+ # CloudScriptApi
2
+
3
+ Tài liệu này dành cho AI code assistant và AI agent nội bộ. Mục tiêu là chọn đúng namespace `client/server/admin`, phân biệt đúng publish version với execute function, và không sinh sai request ở các field `version`, `functionName`, `userId`, `script`.
4
+
5
+ ## 1. Scope
6
+
7
+ - Áp dụng cho:
8
+ - `GNNetwork.cloudScript`
9
+ - `GNNetwork.cloudScript.server`
10
+ - `GNNetwork.cloudScript.admin`
11
+ - Toàn bộ method hiện tại của `CloudScriptApi` đều gửi qua HTTP.
12
+ - `CloudScriptApi` có đủ 3 role thật:
13
+ - `GNNetwork.cloudScript` -> `RequestRole.Client`
14
+ - `GNNetwork.cloudScript.server` -> `RequestRole.Server`
15
+ - `GNNetwork.cloudScript.admin` -> `RequestRole.Admin`
16
+ - Nếu không truyền `overrideSecretKey`, SDK sẽ tự lấy secret key theo role tương ứng.
17
+ - Chỉ dùng namespace `.server` khi bạn đã cấu hình `secretKey` với `permission rules` `server` hợp lệ trong `GNServerSettings`, hoặc chủ động truyền `overrideSecretKey`.
18
+ - Chỉ dùng namespace `.admin` khi bạn đã cấu hình `secretKey` với `permission rules` `admin` hợp lệ trong `GNServerSettings`, hoặc chủ động truyền `overrideSecretKey`.
19
+ - Rule chuẩn để chọn `client/server/admin` và hiểu semantics permission xem [RULES](../RULES.md#3-route--trust-boundary-của-caller). Với nhóm này, không tự suy diễn route chỉ từ target ownership.
20
+ - Public surface hiện chỉ có 5 operation trên mỗi namespace:
21
+ - `addFunctionAsync`
22
+ - `editFunctionAsync`
23
+ - `executeFunctionAsync`
24
+ - `getFunctionAsync`
25
+ - `getFunctionsAsync`
26
+ - `CloudScriptApi` không có public method `removeFunction` hoặc hard-delete version.
27
+ - `CloudScriptApi` không có socket transport, không có realtime event handler riêng.
28
+ - Từ contract hiện tại, `version` đại diện cho một snapshot script đã publish; `functionName` là tên function sẽ được gọi bên trong snapshot đó.
29
+ - `DashboardApi.getEventCallbackCloudScriptAsync` và `setEventCallbackCloudScriptAsync` là nhóm khác; không nằm trong `CloudScriptApi`.
30
+
31
+ ## 2. Hard Rules
32
+
33
+ - Luôn ưu tiên `async/await`. Mặc định dùng `*Async()`.
34
+ - Bắt buộc đã `GNNetwork.init(settings)` trước khi gọi.
35
+ - Không dùng socket cho `CloudScriptApi`.
36
+ - Chọn namespace theo trust boundary:
37
+ - app/player execute function -> `GNNetwork.cloudScript`
38
+ - trusted backend/service -> `GNNetwork.cloudScript.server`
39
+ - dashboard/ops/tooling -> `GNNetwork.cloudScript.admin`
40
+ - Không dùng `GNNetwork.cloudScript` để quản trị version trong production trừ khi backend policy của bạn cho phép rõ ràng.
41
+ - `AddFunctionRequestData.script` là bắt buộc và phải là source script hoàn chỉnh cho version mới.
42
+ - `addFunctionAsync` tạo version mới từ `script`; không phải update tại chỗ một version cũ.
43
+ - `editFunctionAsync` chỉ sửa metadata của version hiện có:
44
+ - `canExecute`
45
+ - `isLive`
46
+ - `editFunctionAsync` không có field `script`; AI không được giả định nó sửa source code.
47
+ - Nếu cần thay đổi source code, phải publish version mới bằng `addFunctionAsync`.
48
+ - `GetFunctionRequestData.version`, `EditFunctionRequestData.version` và `ExecuteFunctionRequestData.version` nếu có đều phải theo đúng version string dài `7` ký tự.
49
+ - `ExecuteFunctionRequestData.functionName` là bắt buộc, độ dài `3..30`.
50
+ - `ExecuteFunctionRequestData.functionParameters` là `any`, nhưng thực tế nên dùng object/array/primitive JSON-serializable.
51
+ - `GNNetwork.cloudScript.executeFunctionAsync` cho phép `userId` optional.
52
+ - `GNNetwork.cloudScript.server.executeFunctionAsync` và `GNNetwork.cloudScript.admin.executeFunctionAsync` bắt buộc có `userId`.
53
+ - `getFunctionsAsync` không nhận filter, không có pagination; request data là object rỗng.
54
+ - `ExecuteFunctionResponseData.status` hiện là số thô; package không export enum public tương ứng.
55
+ - `GetFunctionsResponseData.results[]` chỉ có `version` và `canExecute`.
56
+ - `GetFunctionsResponseData.results[]` không có `isLive`; nếu cần biết version live, phải đọc `liveLatestVersion`.
57
+ - `GetFunctionResponseData` không trả lại `version`; nếu cần giữ `version`, phải giữ từ request hoặc lấy từ danh sách trước đó.
58
+
59
+ ## 3. Chọn Namespace
60
+
61
+ | Namespace | Role thật | Dùng khi nào |
62
+ | --- | --- | --- |
63
+ | `GNNetwork.cloudScript` | `Client` | player app chỉ cần execute function đã được backend cho phép |
64
+ | `GNNetwork.cloudScript.server` | `Server` | trusted backend, worker, game server execute/publish theo workflow backend |
65
+ | `GNNetwork.cloudScript.admin` | `Admin` | dashboard, backoffice, vận hành version, promote live version |
66
+
67
+ Rule nhanh:
68
+
69
+ - Flow execute từ app public: ưu tiên `GNNetwork.cloudScript`.
70
+ - Flow execute thay mặt một user từ backend: ưu tiên `GNNetwork.cloudScript.server`.
71
+ - Flow publish script, promote live version, audit version: ưu tiên `GNNetwork.cloudScript.admin`.
72
+ - Không chọn namespace theo cảm tính; request shape gần giống nhau nhưng trust boundary khác nhau.
73
+
74
+ ## 4. Chọn Method
75
+
76
+ | Method | Dùng khi nào | Cần truyền gì | Nhận được gì | Ghi chú | ErrorCode
77
+ | --- | --- | --- | --- | --- | --- |
78
+ | `addFunctionAsync` | Publish một script version mới | `script`, `canExecute`, `isLive` | `AddFunctionResponseData` | Trả `version` mới và `errorMessage` | `Ok`, `GameNotFound`, `ExecuteError` |
79
+ | `editFunctionAsync` | Bật/tắt execute hoặc promote/demote live cho version cũ | `version`, `canExecute`, `isLive` | `EditFunctionResponseData` | Không sửa `script` | `Ok`, `GameNotFound`, `ExecuteError` |
80
+ | `executeFunctionAsync` | Chạy một function trong CloudScript | `functionName`, `functionParameters?`, `version?`, `userId?` | `ExecuteFunctionResponseData` | `server/admin` bắt buộc có `userId` | `Ok`, `GameNotFound`, `ExecuteError` |
81
+ | `getFunctionAsync` | Đọc chi tiết source và metadata của một version cụ thể | `version` | `GetFunctionResponseData` | Trả `script`, `canExecute`, `isLive`, `tsCreate` | `Ok`, `GameNotFound`, `VersionInvalid` |
82
+ | `getFunctionsAsync` | Liệt kê các version hiện có | request object rỗng | `GetFunctionsResponseData` | Trả `results`, `latestVersion`, `liveLatestVersion` | `Ok`, `GameNotFound` |
83
+
84
+ ## 5. Decision Rules
85
+
86
+ - Cần publish source code mới: dùng `addFunctionAsync`.
87
+ - Cần đổi source code của script đang có: không dùng `editFunctionAsync`; phải tạo version mới bằng `addFunctionAsync`.
88
+ - Cần bật/tắt quyền execute của một version: dùng `editFunctionAsync`.
89
+ - Cần đổi version live: dùng `editFunctionAsync` với đúng `version`.
90
+ - Cần chạy một function business: dùng `executeFunctionAsync`.
91
+ - Cần inspect source code hoặc metadata của đúng một version: dùng `getFunctionAsync`.
92
+ - Cần lấy `latestVersion` hoặc `liveLatestVersion`: dùng `getFunctionsAsync`.
93
+ - Cần cấu hình event callback CloudScript ở hệ thống dashboard: không dùng `CloudScriptApi`; dùng `DashboardApi`.
94
+
95
+ ## 6. Request Rules Và Reference
96
+
97
+ - DTO fields: [reference/dto/CLOUDSCRIPT.md](../reference/dto/CLOUDSCRIPT.md). Method table: [reference/API_CLOUDSCRIPT.md](../reference/API_CLOUDSCRIPT.md).
98
+ - Enums: [ExecuteResponseStatus](../reference/ENUMS.md#executeresponsestatus).
99
+ - Fallback `dist` chỉ khi reference docs chưa đủ: `dist/runtime/entity/models/CloudScript*.d.ts`.
100
+ - `AddFunctionRequestData.script` là bắt buộc.
101
+ - `AddFunctionRequestData.canExecute` và `AddFunctionRequestData.isLive` nên luôn set explicit, không dựa vào default ngầm.
102
+ - `EditFunctionRequestData.version` là bắt buộc, đúng `7` ký tự.
103
+ - `EditFunctionRequestData` không có `script`.
104
+ - `ExecuteFunctionRequestData.functionName` là bắt buộc.
105
+ - `ExecuteFunctionRequestData.version` là optional.
106
+ - `ExecuteFunctionRequestData.userId`:
107
+ - optional ở namespace `client`
108
+ - bắt buộc ở namespace `server`
109
+ - bắt buộc ở namespace `admin`
110
+ - `GetFunctionRequestData.version` là bắt buộc.
111
+ - `GetFunctionsRequestData` hiện không có field nào; không được tự thêm `version`, `skip`, `limit`, `keyword` hoặc filter giả định.
112
+
113
+ ## 7. Response Rules
114
+
115
+ Tất cả typed response của `CloudScriptApi` đều có:
116
+
117
+ - `returnCode`
118
+ - `debugMessage`
119
+ - `invalidMembers`
120
+ - `errorCode`
121
+ - `responseData`
122
+
123
+ Rule kiểm tra response:
124
+
125
+ ```ts
126
+ if (response.hasReturnCodeError()) {
127
+ throw new Error(response.debugMessage);
128
+ }
129
+
130
+ if (response.errorCode !== ErrorCode.Ok) {
131
+ throw new Error(`Business error: ${response.errorCode}`);
132
+ }
133
+ ```
134
+
135
+ Rule bổ sung theo từng operation:
136
+
137
+ - `addFunctionAsync`:
138
+ - đọc `responseData.version` để lấy version mới
139
+ - kiểm tra `responseData.errorMessage` trước khi coi publish là thành công hoàn toàn
140
+ - `editFunctionAsync`:
141
+ - response chỉ có `errorMessage`
142
+ - không có `version` mới, không có `script`
143
+ - `executeFunctionAsync`:
144
+ - đọc `responseData.status`
145
+ - đọc `responseData.functionResult`
146
+ - đọc `responseData.functionLogs`
147
+ - đọc `responseData.errorMessage`
148
+ - đọc `responseData.executionTimeInMs` và `memoryUsedInBytes` nếu cần telemetry
149
+ - `getFunctionAsync`:
150
+ - trả `script`, `canExecute`, `isLive`, `tsCreate`
151
+ - `getFunctionsAsync`:
152
+ - `results[]` chỉ là summary nhẹ
153
+ - dùng `latestVersion` để biết version mới nhất
154
+ - dùng `liveLatestVersion` để biết version live mới nhất
155
+
156
+ ## 8. Best Practices
157
+
158
+ - Ưu tiên `client` cho execute, ưu tiên `server/admin` cho publish và quản trị version.
159
+ - Sau `addFunctionAsync`, luôn lưu lại `responseData.version`.
160
+ - Nếu cần promote live version, nên `getFunctionsAsync` trước để xác nhận `latestVersion` và `liveLatestVersion`.
161
+ - Với `executeFunctionAsync`, giữ `functionParameters` ở dạng JSON đơn giản; tránh class instance, method, circular reference.
162
+ - Với `executeFunctionAsync` ở `server/admin`, giữ `userId` ở biến riêng và truyền explicit.
163
+ - Với debug hoặc vận hành, log lại `functionLogs`, `executionTimeInMs`, `memoryUsedInBytes`.
164
+ - Nếu workflow phụ thuộc source code của một version, lấy lại bằng `getFunctionAsync`; đừng suy diễn từ `getFunctionsAsync`.
165
+ - Nếu cần callback CloudScript cho event hệ thống, chuyển sang `DashboardApi`, không nhét logic đó vào `CloudScriptApi`.
166
+
167
+ ## 9. Ví Dụ Khuyến Nghị
168
+
169
+ ### Admin publish version mới rồi lấy `version`
170
+
171
+ ```ts
172
+ import {
173
+ CloudScriptModels,
174
+ ErrorCode,
175
+ GNNetwork,
176
+ } from "@xmobitea/gn-typescript-client";
177
+
178
+ const request = new CloudScriptModels.AdminAddFunctionRequestData();
179
+ request.script = `
180
+ function ping(args) {
181
+ return {
182
+ ok: true,
183
+ echo: args
184
+ };
185
+ }
186
+ `;
187
+ request.canExecute = true;
188
+ request.isLive = false;
189
+
190
+ const response = await GNNetwork.cloudScript.admin.addFunctionAsync(request);
191
+
192
+ if (response.hasReturnCodeError()) {
193
+ throw new Error(response.debugMessage);
194
+ }
195
+
196
+ if (response.errorCode !== ErrorCode.Ok) {
197
+ throw new Error(`Business error: ${response.errorCode}`);
198
+ }
199
+
200
+ if (response.responseData.errorMessage) {
201
+ throw new Error(response.responseData.errorMessage);
202
+ }
203
+
204
+ const newVersion = response.responseData.version;
205
+ ```
206
+
207
+ ### Admin promote một version thành live
208
+
209
+ ```ts
210
+ import {
211
+ CloudScriptModels,
212
+ ErrorCode,
213
+ GNNetwork,
214
+ } from "@xmobitea/gn-typescript-client";
215
+
216
+ const request = new CloudScriptModels.AdminEditFunctionRequestData();
217
+ request.version = "ABC1234";
218
+ request.canExecute = true;
219
+ request.isLive = true;
220
+
221
+ const response = await GNNetwork.cloudScript.admin.editFunctionAsync(request);
222
+
223
+ if (response.hasReturnCodeError()) {
224
+ throw new Error(response.debugMessage);
225
+ }
226
+
227
+ if (response.errorCode !== ErrorCode.Ok) {
228
+ throw new Error(`Business error: ${response.errorCode}`);
229
+ }
230
+
231
+ if (response.responseData.errorMessage) {
232
+ throw new Error(response.responseData.errorMessage);
233
+ }
234
+ ```
235
+
236
+ ### Server execute function cho một user cụ thể
237
+
238
+ ```ts
239
+ import {
240
+ CloudScriptModels,
241
+ ErrorCode,
242
+ GNNetwork,
243
+ } from "@xmobitea/gn-typescript-client";
244
+
245
+ const request = new CloudScriptModels.ServerExecuteFunctionRequestData();
246
+ request.userId = "USER000001";
247
+ request.functionName = "grantDailyReward";
248
+ request.version = "ABC1234";
249
+ request.functionParameters = {
250
+ rewardId: "daily_01",
251
+ amount: 1
252
+ };
253
+
254
+ const response = await GNNetwork.cloudScript.server.executeFunctionAsync(request);
255
+
256
+ if (response.hasReturnCodeError()) {
257
+ throw new Error(response.debugMessage);
258
+ }
259
+
260
+ if (response.errorCode !== ErrorCode.Ok) {
261
+ throw new Error(`Business error: ${response.errorCode}`);
262
+ }
263
+
264
+ if (response.responseData.errorMessage) {
265
+ throw new Error(response.responseData.errorMessage);
266
+ }
267
+
268
+ const result = response.responseData.functionResult;
269
+ const logs = response.responseData.functionLogs;
270
+ const executionTimeInMs = response.responseData.executionTimeInMs;
271
+ ```
272
+
273
+ ### Đọc summary version rồi lấy source của version live
274
+
275
+ ```ts
276
+ import {
277
+ CloudScriptModels,
278
+ ErrorCode,
279
+ GNNetwork,
280
+ } from "@xmobitea/gn-typescript-client";
281
+
282
+ const listRequest = new CloudScriptModels.GetFunctionsRequestData();
283
+ const listResponse = await GNNetwork.cloudScript.getFunctionsAsync(listRequest);
284
+
285
+ if (listResponse.hasReturnCodeError()) {
286
+ throw new Error(listResponse.debugMessage);
287
+ }
288
+
289
+ if (listResponse.errorCode !== ErrorCode.Ok) {
290
+ throw new Error(`Business error: ${listResponse.errorCode}`);
291
+ }
292
+
293
+ const liveVersion = listResponse.responseData.liveLatestVersion;
294
+
295
+ const getRequest = new CloudScriptModels.GetFunctionRequestData();
296
+ getRequest.version = liveVersion;
297
+
298
+ const getResponse = await GNNetwork.cloudScript.getFunctionAsync(getRequest);
299
+
300
+ if (getResponse.hasReturnCodeError()) {
301
+ throw new Error(getResponse.debugMessage);
302
+ }
303
+
304
+ if (getResponse.errorCode !== ErrorCode.Ok) {
305
+ throw new Error(`Business error: ${getResponse.errorCode}`);
306
+ }
307
+
308
+ const script = getResponse.responseData.script;
309
+ ```
310
+
311
+ ## 10. Anti-Patterns
312
+
313
+ - Không dùng `editFunctionAsync` để đổi source code.
314
+ - Không tự thêm field `script` vào `EditFunctionRequestData`.
315
+ - Không quên `userId` khi dùng `cloudScript.server.executeFunctionAsync` hoặc `cloudScript.admin.executeFunctionAsync`.
316
+ - Không nhầm `version` với `functionName`.
317
+ - Không giả định `getFunctionsAsync` có phân trang hoặc filter.
318
+ - Không suy diễn `isLive` từ `results[]`; phải đọc `liveLatestVersion`.
319
+ - Không bỏ qua `responseData.errorMessage` ở `addFunctionAsync`, `editFunctionAsync`, `executeFunctionAsync`.
320
+ - Không dùng object phức tạp, class instance hoặc circular reference trong `functionParameters`.
321
+ - Không dùng `CloudScriptApi` để cấu hình event callback dashboard.
322
+ - Không giả định package có enum public cho `ExecuteFunctionResponseData.status`.
323
+ - Không giả định SDK có public delete version.
324
+
325
+ ## 11. AI Checklist
326
+
327
+ - Đã `GNNetwork.init(settings)` chưa.
328
+ - Đã chọn đúng namespace `cloudScript` / `cloudScript.server` / `cloudScript.admin` chưa.
329
+ - Nếu đang execute ở `server/admin`, đã truyền `userId` chưa.
330
+ - Nếu đang update source code, có đang dùng sai `editFunctionAsync` thay vì `addFunctionAsync` không.
331
+ - Nếu đang cần version live, có đang đọc `liveLatestVersion` chưa.
332
+ - Nếu đang cần source của một version, có đang dùng `getFunctionAsync` thay vì chỉ nhìn `getFunctionsAsync` không.
333
+ - Nếu đang đọc kết quả execute, có kiểm tra cả `errorCode` lẫn `responseData.errorMessage` chưa.
334
+ - Nếu đang truyền `functionParameters`, có giữ payload JSON-serializable không.
335
+ - Nếu flow là cấu hình event callback CloudScript, có đang dùng nhầm `CloudScriptApi` không.
@@ -0,0 +1,150 @@
1
+ # GearN SDK - Cocos Creator 3.x Integration Guide
2
+
3
+ ## Overview
4
+
5
+ GearN TypeScript SDK dùng được với Cocos Creator 3.x thông qua npm package.
6
+
7
+ ## Installation
8
+
9
+ ### 1. Cài đặt qua npm
10
+
11
+ Trong thư mục project Cocos Creator của bạn:
12
+
13
+ ```bash
14
+ npm install @xmobitea/gn-typescript-client
15
+ ```
16
+
17
+ ### 2. TypeScript Configuration
18
+
19
+ Đảm bảo `tsconfig.json` của project có cấu hình tương thích:
20
+
21
+ ```json
22
+ {
23
+ "compilerOptions": {
24
+ "esModuleInterop": true,
25
+ "experimentalDecorators": true,
26
+ "emitDecoratorMetadata": true
27
+ }
28
+ }
29
+ ```
30
+
31
+ ## Basic Usage
32
+
33
+ ### Initialize SDK
34
+
35
+ ```ts
36
+ import { GNNetwork, GNServerSettings, LogType, MessageType } from "@xmobitea/gn-typescript-client";
37
+
38
+ const settings = new GNServerSettings();
39
+ settings.config({
40
+ serverAddress: "your-server-domain-or-ip",
41
+ serverPort: 2202,
42
+ serverSocketPort: 2901,
43
+ useSsl: false,
44
+ useSocket: true,
45
+ useHttp: true,
46
+ defaultTimeoutInSeconds: 20,
47
+ messageType: MessageType.MsgPack,
48
+ sendRate: 30,
49
+ reconnectDelay: 1000,
50
+ pingInterval: 3000,
51
+ pingTimeout: 5000,
52
+ secretKey: "your-secret-key",
53
+ gameId: "your-game-id",
54
+ logType: LogType.All,
55
+ });
56
+
57
+ GNNetwork.init(settings);
58
+ ```
59
+
60
+ Ghi chú:
61
+
62
+ - Trên browser build của Cocos, nếu `messageType = MessageType.MsgPack` thì HTTP transport sẽ tự fallback sang JSON.
63
+ - Chỉ dùng route `.server` hoặc `.admin` khi bạn đã cấu hình secret key tương ứng.
64
+
65
+ ### Authentication
66
+
67
+ ```ts
68
+ import {
69
+ AuthenticateModels,
70
+ ErrorCode,
71
+ GNNetwork,
72
+ } from "@xmobitea/gn-typescript-client";
73
+
74
+ const infoRequestParam = new AuthenticateModels.InfoRequestParam();
75
+ infoRequestParam.displayName = true;
76
+ infoRequestParam.avatar = true;
77
+
78
+ const request = new AuthenticateModels.LoginByCustomDeviceIdRequestData();
79
+ request.customDeviceId = "unique-device-id";
80
+ request.createPlayerIfNotExists = true;
81
+ request.infoRequestParam = infoRequestParam;
82
+
83
+ const response = await GNNetwork.authenticate.loginByCustomDeviceIdAsync(request);
84
+
85
+ if (response.hasReturnCodeError()) {
86
+ throw new Error(response.debugMessage);
87
+ }
88
+
89
+ if (response.errorCode !== ErrorCode.Ok) {
90
+ throw new Error(`Business error: ${response.errorCode}`);
91
+ }
92
+
93
+ console.log("User ID:", GNNetwork.getAuthenticateStatus().getUserId());
94
+ ```
95
+
96
+ ### Socket Connection
97
+
98
+ Tuân theo [rule socket chuẩn trong RULES](../RULES.md#7-auth--socket-flow).
99
+
100
+ ```ts
101
+ import { GNNetwork } from "@xmobitea/gn-typescript-client";
102
+
103
+ GNNetwork.subscriberOnConnectHandler(() => {
104
+ console.log("Connected!", GNNetwork.getSocketSId());
105
+ });
106
+
107
+ GNNetwork.subscriberOnDisconnectHandler(() => {
108
+ console.log("Disconnected!");
109
+ });
110
+
111
+ GNNetwork.connectSocket(); // Call this after a successful HTTP login or refresh flow.
112
+ ```
113
+
114
+ Nếu socket đã connect trước khi token xuất hiện, hoặc token vừa đổi và bạn không muốn reconnect, gọi `GNNetwork.sendRequestAuthSocket()` để re-auth.
115
+
116
+ ## Platform Detection
117
+
118
+ SDK tự động phát hiện Cocos Creator environment:
119
+
120
+ ```ts
121
+ import { GNSupport } from "@xmobitea/gn-typescript-client";
122
+
123
+ if (GNSupport.isCocosCreator()) {
124
+ console.log("Running in Cocos Creator");
125
+ }
126
+ ```
127
+
128
+ ## Storage
129
+
130
+ SDK tự động dùng `cc.sys.localStorage` trong Cocos Creator để lưu auth token.
131
+
132
+ ## Troubleshooting
133
+
134
+ ### Module not found
135
+
136
+ Đảm bảo bạn đã chạy `npm install` trong đúng project folder.
137
+
138
+ ### Build errors
139
+
140
+ Kiểm tra `tsconfig.json` có `esModuleInterop: true`, `experimentalDecorators: true`, `emitDecoratorMetadata: true`.
141
+
142
+ ### Socket có connect nhưng không nhận event
143
+
144
+ - Kiểm tra app đã login HTTP trước khi `connectSocket()` chưa.
145
+ - Nếu socket connect trước khi token có sẵn, gọi `GNNetwork.sendRequestAuthSocket()` để re-auth.
146
+
147
+ ## Support
148
+
149
+ - GitHub Issues: https://github.com/XmobiTea-Family/GearN-typescript-client-sdk/issues
150
+ - Homepage: https://gearn.net