@xmobitea/gn-typescript-client 2.6.12 → 2.6.13

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 (127) hide show
  1. package/dist/gearn.js.client.js +183 -57
  2. package/dist/gearn.js.client.min.js +1 -1
  3. package/dist/index.d.ts +2 -2
  4. package/dist/index.js +183 -57
  5. package/dist/runtime/GNNetwork.d.ts +1 -1
  6. package/dist/runtime/helper/GNSupport.d.ts +20 -0
  7. package/dist/runtime/{entity → helper}/OperationHelper.d.ts +1 -1
  8. package/dist/runtime/helper/StorageService.d.ts +18 -0
  9. package/dist/runtime/networking/NetworkingPeer.d.ts +1 -1
  10. package/dist/runtime/typescript/ServiceUpdate.d.ts +2 -0
  11. package/docs/COCOS_CREATOR_INTEGRATION.md +116 -0
  12. package/examples/cocos-creator/GearNExample.ts.txt +176 -0
  13. package/package.json +3 -2
  14. package/srcSwift/Package.swift +32 -0
  15. package/srcSwift/Sources/GearN/runtime/GNNetwork.swift +530 -0
  16. package/srcSwift/Sources/GearN/runtime/GNNetworkAuthenticateApi.swift +178 -0
  17. package/srcSwift/Sources/GearN/runtime/GNNetworkCharacterPlayerApi.swift +1162 -0
  18. package/srcSwift/Sources/GearN/runtime/GNNetworkCloudScriptApi.swift +154 -0
  19. package/srcSwift/Sources/GearN/runtime/GNNetworkContentApi.swift +208 -0
  20. package/srcSwift/Sources/GearN/runtime/GNNetworkDashboardApi.swift +240 -0
  21. package/srcSwift/Sources/GearN/runtime/GNNetworkGamePlayerApi.swift +1369 -0
  22. package/srcSwift/Sources/GearN/runtime/GNNetworkGroupApi.swift +1100 -0
  23. package/srcSwift/Sources/GearN/runtime/GNNetworkInventoryApi.swift +937 -0
  24. package/srcSwift/Sources/GearN/runtime/GNNetworkMasterPlayerApi.swift +2323 -0
  25. package/srcSwift/Sources/GearN/runtime/GNNetworkMultiplayerApi.swift +298 -0
  26. package/srcSwift/Sources/GearN/runtime/GNNetworkStoreInventoryApi.swift +397 -0
  27. package/srcSwift/Sources/GearN/runtime/common/Action0.swift +3 -0
  28. package/srcSwift/Sources/GearN/runtime/common/Action1.swift +3 -0
  29. package/srcSwift/Sources/GearN/runtime/common/Action2.swift +3 -0
  30. package/srcSwift/Sources/GearN/runtime/common/Action3.swift +3 -0
  31. package/srcSwift/Sources/GearN/runtime/common/Action4.swift +3 -0
  32. package/srcSwift/Sources/GearN/runtime/common/GNArray.swift +204 -0
  33. package/srcSwift/Sources/GearN/runtime/common/GNData.swift +108 -0
  34. package/srcSwift/Sources/GearN/runtime/common/GNHashtable.swift +200 -0
  35. package/srcSwift/Sources/GearN/runtime/config/GNServerSettings.swift +95 -0
  36. package/srcSwift/Sources/GearN/runtime/constant/Commands.swift +28 -0
  37. package/srcSwift/Sources/GearN/runtime/constant/EventCode.swift +10 -0
  38. package/srcSwift/Sources/GearN/runtime/constant/OperationCode.swift +252 -0
  39. package/srcSwift/Sources/GearN/runtime/constant/ReturnCode.swift +19 -0
  40. package/srcSwift/Sources/GearN/runtime/constant/enumType/ExecuteResponseStatus.swift +9 -0
  41. package/srcSwift/Sources/GearN/runtime/constant/enumType/FriendStatus.swift +8 -0
  42. package/srcSwift/Sources/GearN/runtime/constant/enumType/GoogleLoginType.swift +6 -0
  43. package/srcSwift/Sources/GearN/runtime/constant/enumType/GroupStatus.swift +8 -0
  44. package/srcSwift/Sources/GearN/runtime/constant/enumType/InvalidMemberType.swift +19 -0
  45. package/srcSwift/Sources/GearN/runtime/constant/enumType/ItemType.swift +6 -0
  46. package/srcSwift/Sources/GearN/runtime/constant/enumType/MatchmakingMemberStatus.swift +7 -0
  47. package/srcSwift/Sources/GearN/runtime/constant/enumType/MatchmakingTicketStatus.swift +9 -0
  48. package/srcSwift/Sources/GearN/runtime/constant/enumType/OwnerType.swift +10 -0
  49. package/srcSwift/Sources/GearN/runtime/constant/enumType/PermissionDataItem.swift +6 -0
  50. package/srcSwift/Sources/GearN/runtime/constant/enumType/PushPlatformType.swift +6 -0
  51. package/srcSwift/Sources/GearN/runtime/constant/enumType/RequestRole.swift +7 -0
  52. package/srcSwift/Sources/GearN/runtime/constant/enumType/RequestType.swift +16 -0
  53. package/srcSwift/Sources/GearN/runtime/constant/enumType/StoreItemType.swift +6 -0
  54. package/srcSwift/Sources/GearN/runtime/constant/enumType/StoreReceiveType.swift +9 -0
  55. package/srcSwift/Sources/GearN/runtime/constant/errorCode/ErrorCode.swift +58 -0
  56. package/srcSwift/Sources/GearN/runtime/constant/parameterCode/ParameterCode.swift +672 -0
  57. package/srcSwift/Sources/GearN/runtime/entity/DataMember.swift +196 -0
  58. package/srcSwift/Sources/GearN/runtime/entity/GNMetadata.swift +9 -0
  59. package/srcSwift/Sources/GearN/runtime/entity/InvalidMember.swift +11 -0
  60. package/srcSwift/Sources/GearN/runtime/entity/OperationEvent.swift +38 -0
  61. package/srcSwift/Sources/GearN/runtime/entity/OperationHelper.swift +28 -0
  62. package/srcSwift/Sources/GearN/runtime/entity/OperationRequest.swift +62 -0
  63. package/srcSwift/Sources/GearN/runtime/entity/OperationResponse.swift +98 -0
  64. package/srcSwift/Sources/GearN/runtime/entity/models/AuthenticateModels.swift +351 -0
  65. package/srcSwift/Sources/GearN/runtime/entity/models/AuthenticateRequestModels.swift +81 -0
  66. package/srcSwift/Sources/GearN/runtime/entity/models/AuthenticateResponseModels.swift +108 -0
  67. package/srcSwift/Sources/GearN/runtime/entity/models/CharacterPlayerModels.swift +1045 -0
  68. package/srcSwift/Sources/GearN/runtime/entity/models/CharacterPlayerRequestModels.swift +821 -0
  69. package/srcSwift/Sources/GearN/runtime/entity/models/CharacterPlayerResponseModels.swift +588 -0
  70. package/srcSwift/Sources/GearN/runtime/entity/models/CloudScriptModels.swift +187 -0
  71. package/srcSwift/Sources/GearN/runtime/entity/models/CloudScriptRequestModels.swift +84 -0
  72. package/srcSwift/Sources/GearN/runtime/entity/models/CloudScriptResponseModels.swift +59 -0
  73. package/srcSwift/Sources/GearN/runtime/entity/models/ContentModels.swift +195 -0
  74. package/srcSwift/Sources/GearN/runtime/entity/models/ContentRequestModels.swift +116 -0
  75. package/srcSwift/Sources/GearN/runtime/entity/models/ContentResponseModels.swift +81 -0
  76. package/srcSwift/Sources/GearN/runtime/entity/models/DashboardModels.swift +426 -0
  77. package/srcSwift/Sources/GearN/runtime/entity/models/DashboardRequestModels.swift +160 -0
  78. package/srcSwift/Sources/GearN/runtime/entity/models/DashboardResponseModels.swift +82 -0
  79. package/srcSwift/Sources/GearN/runtime/entity/models/GamePlayerModels.swift +1334 -0
  80. package/srcSwift/Sources/GearN/runtime/entity/models/GamePlayerRequestModels.swift +643 -0
  81. package/srcSwift/Sources/GearN/runtime/entity/models/GamePlayerResponseModels.swift +213 -0
  82. package/srcSwift/Sources/GearN/runtime/entity/models/GenericModels.swift +171 -0
  83. package/srcSwift/Sources/GearN/runtime/entity/models/GroupModels.swift +850 -0
  84. package/srcSwift/Sources/GearN/runtime/entity/models/GroupRequestModels.swift +485 -0
  85. package/srcSwift/Sources/GearN/runtime/entity/models/GroupResponseModels.swift +165 -0
  86. package/srcSwift/Sources/GearN/runtime/entity/models/InventoryModels.swift +679 -0
  87. package/srcSwift/Sources/GearN/runtime/entity/models/InventoryRequestModels.swift +413 -0
  88. package/srcSwift/Sources/GearN/runtime/entity/models/InventoryResponseModels.swift +141 -0
  89. package/srcSwift/Sources/GearN/runtime/entity/models/MasterPlayerModels.swift +378 -0
  90. package/srcSwift/Sources/GearN/runtime/entity/models/MasterPlayerRequestModels.swift +147 -0
  91. package/srcSwift/Sources/GearN/runtime/entity/models/MasterPlayerResponseModels.swift +318 -0
  92. package/srcSwift/Sources/GearN/runtime/entity/models/MultiplayerModels.swift +319 -0
  93. package/srcSwift/Sources/GearN/runtime/entity/models/MultiplayerRequestModels.swift +125 -0
  94. package/srcSwift/Sources/GearN/runtime/entity/models/MultiplayerResponseModels.swift +45 -0
  95. package/srcSwift/Sources/GearN/runtime/entity/models/StoreInventoryModels.swift +633 -0
  96. package/srcSwift/Sources/GearN/runtime/entity/models/StoreInventoryRequestModels.swift +173 -0
  97. package/srcSwift/Sources/GearN/runtime/entity/models/StoreInventoryResponseModels.swift +61 -0
  98. package/srcSwift/Sources/GearN/runtime/entity/request/CustomOperationRequest.swift +42 -0
  99. package/srcSwift/Sources/GearN/runtime/entity/response/CustomOperationResponse.swift +49 -0
  100. package/srcSwift/Sources/GearN/runtime/entity/response/GetAuthInfoResponse.swift +43 -0
  101. package/srcSwift/Sources/GearN/runtime/entity/response/HealthCheckResponse.swift +86 -0
  102. package/srcSwift/Sources/GearN/runtime/entity/response/UploadFileResponse.swift +15 -0
  103. package/srcSwift/Sources/GearN/runtime/helper/CodeHelper.swift +107 -0
  104. package/srcSwift/Sources/GearN/runtime/helper/ConverterService.swift +98 -0
  105. package/srcSwift/Sources/GearN/runtime/helper/EnumUtility.swift +34 -0
  106. package/srcSwift/Sources/GearN/runtime/helper/GNSupport.swift +41 -0
  107. package/srcSwift/Sources/GearN/runtime/helper/GNUtils.swift +66 -0
  108. package/srcSwift/Sources/GearN/runtime/helper/MessagePackConverterService.swift +21 -0
  109. package/srcSwift/Sources/GearN/runtime/helper/StorageService.swift +29 -0
  110. package/srcSwift/Sources/GearN/runtime/logger/GNDebug.swift +33 -0
  111. package/srcSwift/Sources/GearN/runtime/networking/AuthenticateStatus.swift +24 -0
  112. package/srcSwift/Sources/GearN/runtime/networking/IPeer.swift +8 -0
  113. package/srcSwift/Sources/GearN/runtime/networking/NetworkingPeer.swift +368 -0
  114. package/srcSwift/Sources/GearN/runtime/networking/OperationPending.swift +81 -0
  115. package/srcSwift/Sources/GearN/runtime/networking/PeerBase.swift +228 -0
  116. package/srcSwift/Sources/GearN/runtime/networking/handler/IServerEventHandler.swift +20 -0
  117. package/srcSwift/Sources/GearN/runtime/networking/http/HttpPeer.swift +226 -0
  118. package/srcSwift/Sources/GearN/runtime/networking/http/HttpTypes.swift +24 -0
  119. package/srcSwift/Sources/GearN/runtime/networking/http/NetworkingHttpPeerBase.swift +13 -0
  120. package/srcSwift/Sources/GearN/runtime/networking/http/NetworkingPeerUrlSession.swift +125 -0
  121. package/srcSwift/Sources/GearN/runtime/networking/request/NetRequest.swift +19 -0
  122. package/srcSwift/Sources/GearN/runtime/networking/response/NetResponse.swift +13 -0
  123. package/srcSwift/Sources/GearN/runtime/networking/socket/NetworkingPeerSocketIOClient.swift +244 -0
  124. package/srcSwift/Sources/GearN/runtime/networking/socket/NetworkingSocketPeerBase.swift +59 -0
  125. package/srcSwift/Sources/GearN/runtime/networking/socket/SocketPeer.swift +136 -0
  126. package/tsconfig-build.cocos.json +31 -0
  127. package/webpack.config.cocos.mjs +78 -0
@@ -0,0 +1,176 @@
1
+ /**
2
+ * GearNExample.ts - Example Cocos Creator 3.x Component using GearN SDK
3
+ *
4
+ * This component demonstrates how to integrate the GearN SDK
5
+ * with a Cocos Creator 3.x project.
6
+ *
7
+ * Installation:
8
+ * 1. npm install @xmobitea/gn-typescript-client
9
+ * 2. Copy this file to your Cocos Creator project's scripts folder
10
+ * 3. Attach to a Node in your scene
11
+ */
12
+
13
+ import { _decorator, Component, log, warn, error } from 'cc';
14
+
15
+ // Import GearN SDK
16
+ import {
17
+ GNNetwork,
18
+ GNServerSettings,
19
+ GNServerSettingsOptions,
20
+ LogType,
21
+ MessageType
22
+ } from '@xmobitea/gn-typescript-client';
23
+
24
+ const { ccclass, property } = _decorator;
25
+
26
+ @ccclass('GearNExample')
27
+ export class GearNExample extends Component {
28
+
29
+ @property({ tooltip: "GearN Server HTTP URL" })
30
+ httpUrl: string = "http://localhost:8080";
31
+
32
+ @property({ tooltip: "GearN Server Socket URL" })
33
+ socketUrl: string = "ws://localhost:8080";
34
+
35
+ @property({ tooltip: "Your Game/App Secret Key" })
36
+ secretKey: string = "";
37
+
38
+ @property({ tooltip: "Enable debug logging" })
39
+ enableDebugLog: boolean = true;
40
+
41
+ start() {
42
+ this.initializeGearN();
43
+ }
44
+
45
+ /**
46
+ * Initialize GearN SDK
47
+ */
48
+ private initializeGearN(): void {
49
+ try {
50
+ // Create server settings
51
+ const settings: GNServerSettingsOptions = {
52
+ httpUrl: this.httpUrl,
53
+ socketUrl: this.socketUrl,
54
+ secretKey: this.secretKey,
55
+ useSocket: true,
56
+ useHttp: true,
57
+ logType: this.enableDebugLog ? LogType.All : LogType.None,
58
+ sendRate: 30,
59
+ messageType: MessageType.MsgPack,
60
+ socketReconnectDelay: 1000,
61
+ socketPingInterval: 3000,
62
+ socketPingTimeout: 5000,
63
+ httpRequestTimeout: 10,
64
+ };
65
+
66
+ const gnServerSettings = new GNServerSettings(settings);
67
+
68
+ // Initialize GearN
69
+ GNNetwork.init(gnServerSettings);
70
+
71
+ log('[GearN] SDK initialized successfully!');
72
+ log('[GearN] Platform:', GNNetwork.getPlatform());
73
+
74
+ // Subscribe to connection events
75
+ this.setupConnectionHandlers();
76
+
77
+ } catch (err) {
78
+ error('[GearN] Failed to initialize SDK:', err);
79
+ }
80
+ }
81
+
82
+ /**
83
+ * Setup socket connection event handlers
84
+ */
85
+ private setupConnectionHandlers(): void {
86
+ GNNetwork.subscriberOnConnectHandler(() => {
87
+ log('[GearN] Socket connected! SID:', GNNetwork.getSocketSId());
88
+
89
+ // Authenticate after connection
90
+ this.onSocketConnected();
91
+ });
92
+
93
+ GNNetwork.subscriberOnDisconnectHandler(() => {
94
+ warn('[GearN] Socket disconnected!');
95
+ });
96
+ }
97
+
98
+ /**
99
+ * Called when socket is connected
100
+ */
101
+ private onSocketConnected(): void {
102
+ // Example: Send auth token if already logged in
103
+ const authStatus = GNNetwork.getAuthenticateStatus();
104
+ if (authStatus.getAuthToken()) {
105
+ GNNetwork.sendRequestAuthSocket();
106
+ log('[GearN] Auth token sent to socket');
107
+ }
108
+ }
109
+
110
+ /**
111
+ * Connect to socket server
112
+ */
113
+ public connectSocket(): void {
114
+ log('[GearN] Connecting to socket...');
115
+ GNNetwork.connectSocket(() => {
116
+ log('[GearN] Socket connection initiated');
117
+ });
118
+ }
119
+
120
+ /**
121
+ * Disconnect from socket server
122
+ */
123
+ public disconnectSocket(): void {
124
+ log('[GearN] Disconnecting from socket...');
125
+ GNNetwork.disconnectSocket(() => {
126
+ log('[GearN] Socket disconnected');
127
+ });
128
+ }
129
+
130
+ /**
131
+ * Example: Login with device ID
132
+ */
133
+ public async loginWithDeviceId(deviceId: string): Promise<void> {
134
+ try {
135
+ log('[GearN] Logging in with device ID:', deviceId);
136
+
137
+ const response = await GNNetwork.authenticate.loginDeviceIdAsync({
138
+ deviceId: deviceId,
139
+ createAccount: true,
140
+ });
141
+
142
+ if (response.hasError()) {
143
+ error('[GearN] Login failed:', response.getDebugMessage());
144
+ return;
145
+ }
146
+
147
+ log('[GearN] Login successful!');
148
+ log('[GearN] User ID:', GNNetwork.getAuthenticateStatus().getUserId());
149
+
150
+ // Connect socket after successful login
151
+ this.connectSocket();
152
+
153
+ } catch (err) {
154
+ error('[GearN] Login error:', err);
155
+ }
156
+ }
157
+
158
+ /**
159
+ * Example: Get server health status
160
+ */
161
+ public async checkServerHealth(): Promise<void> {
162
+ try {
163
+ const response = await GNNetwork.healthCheckAsync();
164
+ log('[GearN] Server health:', response);
165
+ } catch (err) {
166
+ error('[GearN] Health check failed:', err);
167
+ }
168
+ }
169
+
170
+ onDestroy() {
171
+ // Cleanup: disconnect socket when component is destroyed
172
+ if (GNNetwork.isSocketConnected()) {
173
+ GNNetwork.disconnectSocket();
174
+ }
175
+ }
176
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xmobitea/gn-typescript-client",
3
- "version": "2.6.12",
3
+ "version": "2.6.13",
4
4
  "description": "GearN Typescript Client SDK by XmobiTea (Pro)",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
@@ -13,6 +13,7 @@
13
13
  "build:minudm": "webpack --config webpack.config.min.udm.mjs --mode production --stats-modules",
14
14
  "build": "rm -rf ./dist && npm run build:node && npm run build:udm && npm run build:minudm",
15
15
  "build:withoutwebpack": "rm -rf ./dist && tsc",
16
+ "build:cocos": "rm -rf ./dist && webpack --config webpack.config.cocos.mjs --mode production --stats-modules",
16
17
  "push": "npm run build && npm publish && git push"
17
18
  },
18
19
  "author": "changx.develop@gmail.com (https://xmobitea.com)",
@@ -62,4 +63,4 @@
62
63
  "engines": {
63
64
  "node": ">=20.0.0"
64
65
  }
65
- }
66
+ }
@@ -0,0 +1,32 @@
1
+ // swift-tools-version: 5.7
2
+ // The swift-tools-version declares the minimum version of Swift required to build this package.
3
+
4
+ import PackageDescription
5
+
6
+ let package = Package(
7
+ name: "GearN",
8
+ products: [
9
+ // Products define the executables and libraries a package produces, making them visible to other packages.
10
+ .library(
11
+ name: "GearN",
12
+ targets: ["GearN"]),
13
+ ],
14
+ dependencies: [
15
+ // Dependencies declare other packages that this package depends on.
16
+ .package(url: "https://github.com/socketio/socket.io-client-swift", from: "16.1.1"),
17
+ ],
18
+ targets: [
19
+ // Targets are the basic building blocks of a package, defining a module or a test suite.
20
+ // Targets can depend on other targets in this package and products from dependencies.
21
+ .target(
22
+ name: "GearN",
23
+ dependencies: [
24
+ .product(name: "SocketIO", package: "socket.io-client-swift")
25
+ ],
26
+ path: "Sources/GearN"),
27
+ .testTarget(
28
+ name: "GearNTests",
29
+ dependencies: ["GearN"],
30
+ path: "Tests/GearNTests"),
31
+ ]
32
+ )