@xmobitea/gn-typescript-client 2.6.10-tsc → 2.6.11-tsc

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.
@@ -26,6 +26,7 @@ import { MultiplayerApi } from "./GNNetworkMultiplayerApi";
26
26
  import { CloudScriptApi } from "./GNNetworkCloudScriptApi";
27
27
  import { GetAuthInfoResponse } from "./entity/response/GetAuthInfoResponse";
28
28
  import { UploadFileResponse } from "./entity/response/UploadFileResponse";
29
+ import { HealthCheckResponse } from "./entity/response/HealthCheckResponse";
29
30
  export declare class GNNetwork {
30
31
  static readonly AUTH_TOKEN_KEY = "[GearN]_AUTH_TOKEN_KEY";
31
32
  static readonly USER_ID_KEY = "[GearN]_USER_ID_KEY";
@@ -83,6 +84,8 @@ export declare class GNNetwork {
83
84
  static syncTsAsync(): Promise<number>;
84
85
  static getAuthInfo(authToken: string, onResponse?: Action1<GetAuthInfoResponse>): void;
85
86
  static getAuthInfoAsync(authToken: string): Promise<GetAuthInfoResponse>;
87
+ static healthCheck(onResponse?: Action1<HealthCheckResponse>): void;
88
+ static healthCheckAsync(): Promise<HealthCheckResponse>;
86
89
  static uploadFile(fileId: string, content: Uint8Array, filename: string, mimetype: string, onResponse?: Action1<UploadFileResponse>): void;
87
90
  static uploadFileAsync(fileId: string, content: Uint8Array, filename: string, mimetype: string): Promise<UploadFileResponse>;
88
91
  static getDownloadFileUrl(downloadToken: string): string;
@@ -231,6 +231,16 @@ export class GNNetwork {
231
231
  });
232
232
  });
233
233
  }
234
+ static healthCheck(onResponse = null) {
235
+ GNNetwork.peer.healthCheck(onResponse);
236
+ }
237
+ static healthCheckAsync() {
238
+ return new Promise((resolve) => {
239
+ GNNetwork.healthCheck((response) => {
240
+ resolve(response);
241
+ });
242
+ });
243
+ }
234
244
  static uploadFile(fileId, content, filename, mimetype, onResponse = null) {
235
245
  GNNetwork.peer.uploadFile(fileId, content, filename, mimetype, onResponse);
236
246
  }
@@ -0,0 +1,21 @@
1
+ interface InstanceResponse {
2
+ instanceId: string;
3
+ isPrimary: boolean;
4
+ currentInstanceIdPrimary: string;
5
+ currentTsPrimary: number;
6
+ currentTsPrimaryToDate: string;
7
+ tsPrimary: number;
8
+ tsPrimaryToDate: string;
9
+ }
10
+ interface OtherInstanceResponse extends InstanceResponse {
11
+ lostPing: number;
12
+ }
13
+ interface HealthCheckDataResponse {
14
+ thisInstance: InstanceResponse;
15
+ otherInstances: OtherInstanceResponse[];
16
+ }
17
+ export declare class HealthCheckResponse {
18
+ error: string;
19
+ data?: HealthCheckDataResponse;
20
+ }
21
+ export {};
@@ -0,0 +1,2 @@
1
+ export class HealthCheckResponse {
2
+ }
@@ -10,9 +10,11 @@ import { RequestType } from "./../constant/enumType/RequestType";
10
10
  import { RequestRole } from "./../constant/enumType/RequestRole";
11
11
  import { GetAuthInfoResponse } from "./../entity/response/GetAuthInfoResponse";
12
12
  import { UploadFileResponse } from "./../entity/response/UploadFileResponse";
13
+ import { HealthCheckResponse } from "../entity/response/HealthCheckResponse";
13
14
  export declare class NetworkingPeer {
14
15
  static readonly SYNC_TS: string;
15
16
  static readonly GET_AUTH_INFO: string;
17
+ static readonly HEALTH_CHECK: string;
16
18
  static readonly UPLOAD_FILE: string;
17
19
  static readonly DOWNLOAD_FILE: string;
18
20
  static readonly API_JSON: string;
@@ -42,5 +44,6 @@ export declare class NetworkingPeer {
42
44
  subscriberServerEventHandler(serverEventHandler: IServerEventHandler): void;
43
45
  syncTs(onResponse?: Action1<number>): void;
44
46
  getAuthInfo(authToken: string, onResponse: Action1<GetAuthInfoResponse>): void;
47
+ healthCheck(onResponse: Action1<HealthCheckResponse>): void;
45
48
  uploadFile(fileId: string, content: Uint8Array, filename: string, mimetype: string, onResponse: Action1<UploadFileResponse>): void;
46
49
  }
@@ -149,6 +149,35 @@ export class NetworkingPeer {
149
149
  });
150
150
  });
151
151
  }
152
+ healthCheck(onResponse) {
153
+ this.httpPeer.getRequest(NetworkingPeer.HEALTH_CHECK, (httpAppResponse) => {
154
+ if (!httpAppResponse.hasError()) {
155
+ if (httpAppResponse.statusCode == 200) {
156
+ let returnDatas = JSON.parse(httpAppResponse.text);
157
+ if (returnDatas.error) {
158
+ if (onResponse != null)
159
+ onResponse({
160
+ error: returnDatas.error,
161
+ });
162
+ }
163
+ else {
164
+ if (onResponse != null) {
165
+ let response = {
166
+ error: null,
167
+ data: returnDatas.data,
168
+ };
169
+ onResponse(response);
170
+ }
171
+ }
172
+ return;
173
+ }
174
+ }
175
+ if (onResponse != null)
176
+ onResponse({
177
+ error: httpAppResponse.error,
178
+ });
179
+ });
180
+ }
152
181
  uploadFile(fileId, content, filename, mimetype, onResponse) {
153
182
  this.httpPeer.uploadFile(fileId, content, filename, mimetype, (httpAppResponse) => {
154
183
  var _a;
@@ -172,6 +201,7 @@ export class NetworkingPeer {
172
201
  }
173
202
  NetworkingPeer.SYNC_TS = "ts";
174
203
  NetworkingPeer.GET_AUTH_INFO = "getAuthInfo";
204
+ NetworkingPeer.HEALTH_CHECK = "healthcheck";
175
205
  NetworkingPeer.UPLOAD_FILE = "upload";
176
206
  NetworkingPeer.DOWNLOAD_FILE = "download";
177
207
  NetworkingPeer.API_JSON = "api/" + Commands.RequestCmd_Json;
@@ -133,7 +133,7 @@ export class NetworkingPeerAxiosRequest extends NetworkingHttpPeerBase {
133
133
  }
134
134
  async postRequestUploadAxios(subUri, content, filename, mimetype, onHttpAppResponse, timeout) {
135
135
  let formData = new FormData();
136
- formData.append(Commands.File, new Blob([content], { type: mimetype }), filename);
136
+ formData.append(Commands.File, new Blob([content.buffer.slice(0)], { type: mimetype }), filename);
137
137
  let headers = {};
138
138
  headers[Commands.RequestAuthTokenCmd] = GNNetwork.getAuthenticateStatus().getAuthToken();
139
139
  ;
@@ -20,7 +20,7 @@ export class NetworkingPeerSocketIOClient extends NetworkingSocketPeerBase {
20
20
  if (this.socketManager == null) {
21
21
  const url = new URL(this.url);
22
22
  this.socketManager = new Manager(url.origin, {
23
- path: url.pathname + "/socket.io",
23
+ path: url.pathname + "socket.io",
24
24
  reconnection: true,
25
25
  reconnectionDelay: this.reconnectDelay,
26
26
  timeout: this.pingTimeout,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xmobitea/gn-typescript-client",
3
- "version": "2.6.10-tsc",
3
+ "version": "2.6.11-tsc",
4
4
  "description": "GearN Typescript Client SDK by XmobiTea (Pro)",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",