@xmobitea/gn-typescript-client 2.5.2-esnext → 2.5.3-esnext
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.
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/runtime/GNNetwork.d.ts +4 -0
- package/dist/runtime/GNNetwork.js +53 -61
- package/dist/runtime/GNNetworkAuthenticateApi.js +36 -81
- package/dist/runtime/GNNetworkCharacterPlayerApi.js +318 -645
- package/dist/runtime/GNNetworkCloudScriptApi.js +30 -69
- package/dist/runtime/GNNetworkContentApi.js +42 -93
- package/dist/runtime/GNNetworkDashboardApi.js +52 -113
- package/dist/runtime/GNNetworkGamePlayerApi.js +312 -633
- package/dist/runtime/GNNetworkGroupApi.js +240 -489
- package/dist/runtime/GNNetworkInventoryApi.js +204 -417
- package/dist/runtime/GNNetworkMasterPlayerApi.js +512 -1033
- package/dist/runtime/GNNetworkMultiplayerApi.js +60 -129
- package/dist/runtime/GNNetworkStoreInventoryApi.js +84 -177
- package/dist/runtime/constant/enumType/OwnerType.d.ts +2 -1
- package/dist/runtime/constant/enumType/OwnerType.js +1 -0
- package/dist/runtime/entity/models/AuthenticateModels.d.ts +1 -1
- package/dist/runtime/entity/models/AuthenticateModels.js +1 -1
- package/dist/runtime/entity/models/CharacterPlayerModels.d.ts +1 -0
- package/dist/runtime/entity/models/CharacterPlayerModels.js +4 -0
- package/dist/runtime/entity/models/ContentModels.d.ts +0 -2
- package/dist/runtime/entity/models/ContentModels.js +0 -8
- package/dist/runtime/entity/models/GamePlayerModels.d.ts +1 -0
- package/dist/runtime/entity/models/GamePlayerModels.js +4 -0
- package/dist/runtime/entity/models/MasterPlayerModels.d.ts +1 -1
- package/dist/runtime/entity/models/MasterPlayerModels.js +1 -1
- package/dist/runtime/entity/response/UploadFileResponse.d.ts +3 -0
- package/dist/runtime/entity/response/UploadFileResponse.js +2 -0
- package/dist/runtime/helper/GNUtils.d.ts +1 -1
- package/dist/runtime/helper/MessagePackConverterService.d.ts +4 -0
- package/dist/runtime/helper/MessagePackConverterService.js +9 -0
- package/dist/runtime/networking/NetworkingPeer.d.ts +3 -1
- package/dist/runtime/networking/NetworkingPeer.js +20 -1
- package/dist/runtime/networking/http/HttpPeer.d.ts +1 -1
- package/dist/runtime/networking/http/HttpPeer.js +4 -4
- package/dist/runtime/networking/http/NetworkingHttpPeerBase.d.ts +1 -1
- package/dist/runtime/networking/http/NetworkingPeerAxiosRequest.d.ts +2 -1
- package/dist/runtime/networking/http/NetworkingPeerAxiosRequest.js +122 -104
- package/dist/runtime/networking/socket/NetworkingPeerSocketIOClient.d.ts +0 -1
- package/dist/runtime/networking/socket/NetworkingPeerSocketIOClient.js +2 -2
- package/dist/runtime/networking/socket/NetworkingSocketPeerBase.js +3 -3
- package/package.json +7 -6
|
@@ -336,6 +336,7 @@ export declare namespace GamePlayerModels {
|
|
|
336
336
|
userId?: string;
|
|
337
337
|
catalogId: string;
|
|
338
338
|
displayName?: string;
|
|
339
|
+
uniqueDisplayName?: boolean;
|
|
339
340
|
}
|
|
340
341
|
class ServerGrantPlayerCharacterRequestData extends GrantPlayerCharacterRequestData {
|
|
341
342
|
userId: string;
|
|
@@ -874,6 +874,10 @@ export var GamePlayerModels;
|
|
|
874
874
|
StringDataMember({ code: GNParameterCode.DisplayName, defaultValue: "", isOptional: true, mustNonNull: true }),
|
|
875
875
|
__metadata("design:type", String)
|
|
876
876
|
], GrantPlayerCharacterRequestData.prototype, "displayName", void 0);
|
|
877
|
+
__decorate([
|
|
878
|
+
BooleanDataMember({ code: GNParameterCode.UniqueDisplayName, defaultValue: false, isOptional: true }),
|
|
879
|
+
__metadata("design:type", Boolean)
|
|
880
|
+
], GrantPlayerCharacterRequestData.prototype, "uniqueDisplayName", void 0);
|
|
877
881
|
GamePlayerModels.GrantPlayerCharacterRequestData = GrantPlayerCharacterRequestData;
|
|
878
882
|
class ServerGrantPlayerCharacterRequestData extends GrantPlayerCharacterRequestData {
|
|
879
883
|
}
|
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
import { GNHashtable } from "
|
|
10
|
+
import { GNHashtable } from "./../../common/GNData";
|
|
11
11
|
import { GNParameterCode } from "./../../constant/parameterCode/GNParameterCode";
|
|
12
12
|
import { GNHashtableDataMember, StringDataMember, BooleanDataMember, DataMember, GNArrayDataMember, NumberDataMember } from "./../DataMember";
|
|
13
13
|
import { GenericModels } from "./GenericModels";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GenericModels } from "
|
|
1
|
+
import { GenericModels } from "./../entity/models/GenericModels";
|
|
2
2
|
export declare class GNUtils {
|
|
3
3
|
static toDatasDictionary(datas: Array<GenericModels.DataItem>): Map<string, GenericModels.DataItem>;
|
|
4
4
|
static toTagsDictionary(tags: Array<GenericModels.TagItem>): Map<string, GenericModels.TagItem>;
|
|
@@ -8,7 +8,8 @@ import { OperationEvent } from "./../entity/OperationEvent";
|
|
|
8
8
|
import { AuthenticateStatus } from "./AuthenticateStatus";
|
|
9
9
|
import { RequestType } from "./../constant/enumType/RequestType";
|
|
10
10
|
import { RequestRole } from "./../constant/enumType/RequestRole";
|
|
11
|
-
import { GetAuthInfoResponse } from "
|
|
11
|
+
import { GetAuthInfoResponse } from "./../entity/response/GetAuthInfoResponse";
|
|
12
|
+
import { UploadFileResponse } from "./../entity/response/UploadFileResponse";
|
|
12
13
|
export declare class NetworkingPeer {
|
|
13
14
|
static readonly SYNC_TS: string;
|
|
14
15
|
static readonly GET_AUTH_INFO: string;
|
|
@@ -41,4 +42,5 @@ export declare class NetworkingPeer {
|
|
|
41
42
|
subscriberServerEventHandler(serverEventHandler: IServerEventHandler): void;
|
|
42
43
|
syncTs(onResponse?: Action1<number>): void;
|
|
43
44
|
getAuthInfo(authToken: string, onResponse: Action1<GetAuthInfoResponse>): void;
|
|
45
|
+
uploadFile(fileId: string, content: Uint8Array, filename: string, mimetype: string, onResponse: Action1<UploadFileResponse>): void;
|
|
44
46
|
}
|
|
@@ -122,7 +122,6 @@ export class NetworkingPeer {
|
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
124
|
getAuthInfo(authToken, onResponse) {
|
|
125
|
-
let thiz = this;
|
|
126
125
|
this.httpPeer.getRequest(NetworkingPeer.GET_AUTH_INFO + "?authToken=" + authToken, (httpAppResponse) => {
|
|
127
126
|
if (!httpAppResponse.hasError()) {
|
|
128
127
|
if (httpAppResponse.statusCode == 200) {
|
|
@@ -154,6 +153,26 @@ export class NetworkingPeer {
|
|
|
154
153
|
});
|
|
155
154
|
});
|
|
156
155
|
}
|
|
156
|
+
uploadFile(fileId, content, filename, mimetype, onResponse) {
|
|
157
|
+
this.httpPeer.uploadFile(fileId, content, filename, mimetype, (httpAppResponse) => {
|
|
158
|
+
var _a;
|
|
159
|
+
if (!httpAppResponse.hasError()) {
|
|
160
|
+
if (httpAppResponse.statusCode == 200) {
|
|
161
|
+
if (onResponse != null) {
|
|
162
|
+
let response = {
|
|
163
|
+
error: null,
|
|
164
|
+
};
|
|
165
|
+
onResponse(response);
|
|
166
|
+
}
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (onResponse != null)
|
|
171
|
+
onResponse({
|
|
172
|
+
error: (_a = httpAppResponse.error) !== null && _a !== void 0 ? _a : "Unknown Error",
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
}
|
|
157
176
|
}
|
|
158
177
|
NetworkingPeer.SYNC_TS = "ts";
|
|
159
178
|
NetworkingPeer.GET_AUTH_INFO = "getAuthInfo";
|
|
@@ -21,5 +21,5 @@ export declare class HttpPeer extends PeerBase {
|
|
|
21
21
|
protected onEnqueue(operationPending: OperationPending): void;
|
|
22
22
|
private onSendOperationRequestResponse;
|
|
23
23
|
getRequest(subUri: string, onHttpAppResponse: Action1<HttpAppResponse>, timeout?: number, authToken?: string, secretKey?: string, gameId?: string): void;
|
|
24
|
-
uploadFile(fileId: string, content: Uint8Array, mimetype: string, onHttpAppResponse: Action1<HttpAppResponse>, timeout?: number): void;
|
|
24
|
+
uploadFile(fileId: string, content: Uint8Array, filename: string, mimetype: string, onHttpAppResponse: Action1<HttpAppResponse>, timeout?: number): void;
|
|
25
25
|
}
|
|
@@ -6,8 +6,8 @@ import { NetworkingPeer } from "./../NetworkingPeer";
|
|
|
6
6
|
import { PeerBase } from "./../PeerBase";
|
|
7
7
|
import { NetworkingSocketPeerBase } from "./../socket/NetworkingSocketPeerBase";
|
|
8
8
|
import { GNSupport } from "./../../helper/GNSupport";
|
|
9
|
-
import { decode } from "@msgpack/msgpack";
|
|
10
9
|
import { NetworkingPeerAxiosRequest } from "./NetworkingPeerAxiosRequest";
|
|
10
|
+
import { MessagePackConverterService } from "./../../helper/MessagePackConverterService";
|
|
11
11
|
export class HttpAppResponse {
|
|
12
12
|
hasError() {
|
|
13
13
|
return this.error != null;
|
|
@@ -77,7 +77,7 @@ export class HttpPeer extends PeerBase {
|
|
|
77
77
|
}
|
|
78
78
|
if (gnArray == null) {
|
|
79
79
|
if (httpAppResponse.data != null) {
|
|
80
|
-
let iList =
|
|
80
|
+
let iList = MessagePackConverterService.deserialize(httpAppResponse.data);
|
|
81
81
|
gnArray = GNArray.builder()
|
|
82
82
|
.addAll(NetworkingSocketPeerBase.fromMsgList(iList))
|
|
83
83
|
.build();
|
|
@@ -107,7 +107,7 @@ export class HttpPeer extends PeerBase {
|
|
|
107
107
|
getRequest(subUri, onHttpAppResponse, timeout = 15, authToken = null, secretKey = null, gameId = null) {
|
|
108
108
|
this.networkingHttpPeerBase.getRequest(subUri, onHttpAppResponse, timeout, authToken, secretKey, gameId);
|
|
109
109
|
}
|
|
110
|
-
uploadFile(fileId, content, mimetype, onHttpAppResponse, timeout =
|
|
110
|
+
uploadFile(fileId, content, filename, mimetype, onHttpAppResponse, timeout = 6000) {
|
|
111
111
|
let authToken = GNNetwork.getAuthenticateStatus().getAuthToken();
|
|
112
112
|
if (!authToken) {
|
|
113
113
|
let httpAppResponse = new HttpAppResponse();
|
|
@@ -118,7 +118,7 @@ export class HttpPeer extends PeerBase {
|
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
120
120
|
let subUri = NetworkingPeer.UPLOAD_FILE + "/" + fileId;
|
|
121
|
-
this.networkingHttpPeerBase.postRequestUpload(subUri, content, mimetype, onHttpAppResponse, timeout);
|
|
121
|
+
this.networkingHttpPeerBase.postRequestUpload(subUri, content, filename, mimetype, onHttpAppResponse, timeout);
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
HttpPeer.JSON_CHAR_KNOWN = "[";
|
|
@@ -6,6 +6,6 @@ export declare abstract class NetworkingHttpPeerBase {
|
|
|
6
6
|
protected userAgent: string;
|
|
7
7
|
abstract getRequest(subUri: string, onHttpAppResponse: Action1<HttpAppResponse>, timeout: number, authToken: string, secretKey: string, gameId: string): void;
|
|
8
8
|
abstract postRequest(subUri: string, param: GNHashtable, postType: PostType, onHttpAppResponse: Action1<HttpAppResponse>, timeout: number, authToken: string, secretKey: string, customTags: GNHashtable, gameId: string): void;
|
|
9
|
-
abstract postRequestUpload(subUri: string, content: Uint8Array, mimetype: string, onHttpAppResponse: Action1<HttpAppResponse>, timeout: number): void;
|
|
9
|
+
abstract postRequestUpload(subUri: string, content: Uint8Array, filename: string, mimetype: string, onHttpAppResponse: Action1<HttpAppResponse>, timeout: number): void;
|
|
10
10
|
init(httpUrl: string, userAgent: string): void;
|
|
11
11
|
}
|
|
@@ -5,9 +5,10 @@ import { NetworkingHttpPeerBase } from "./NetworkingHttpPeerBase";
|
|
|
5
5
|
export declare class NetworkingPeerAxiosRequest extends NetworkingHttpPeerBase {
|
|
6
6
|
getRequest(subUri: string, onHttpAppResponse: Action1<HttpAppResponse>, timeout: number, authToken: string, secretKey: string, gameId: string): void;
|
|
7
7
|
postRequest(subUri: string, param: GNHashtable, postType: PostType, onHttpAppResponse: Action1<HttpAppResponse>, timeout: number, authToken: string, secretKey: string, customTags: GNHashtable, gameId: string): void;
|
|
8
|
-
postRequestUpload(subUri: string, content: Uint8Array, mimetype: string, onHttpAppResponse: Action1<HttpAppResponse>, timeout: number): void;
|
|
8
|
+
postRequestUpload(subUri: string, content: Uint8Array, filename: string, mimetype: string, onHttpAppResponse: Action1<HttpAppResponse>, timeout: number): void;
|
|
9
9
|
private getRequestAxios;
|
|
10
10
|
private postRequestAxios;
|
|
11
|
+
private postRequestUploadAxios;
|
|
11
12
|
private uint8ArrayToString;
|
|
12
13
|
private toBuffers;
|
|
13
14
|
}
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import axios from "axios";
|
|
11
2
|
import { GNHashtable } from "./../../common/GNData";
|
|
12
3
|
import { Commands } from "./../../constant/Commands";
|
|
@@ -15,7 +6,8 @@ import { GNDebug } from "./../../logger/GNDebug";
|
|
|
15
6
|
import { HttpAppResponse, PostType } from "./HttpPeer";
|
|
16
7
|
import { NetworkingHttpPeerBase } from "./NetworkingHttpPeerBase";
|
|
17
8
|
import { GNParameterCode } from "./../../constant/parameterCode/GNParameterCode";
|
|
18
|
-
import {
|
|
9
|
+
import { GNNetwork } from "./../../GNNetwork";
|
|
10
|
+
import { MessagePackConverterService } from "./../../helper/MessagePackConverterService";
|
|
19
11
|
export class NetworkingPeerAxiosRequest extends NetworkingHttpPeerBase {
|
|
20
12
|
getRequest(subUri, onHttpAppResponse, timeout, authToken, secretKey, gameId) {
|
|
21
13
|
this.getRequestAxios(subUri, onHttpAppResponse, timeout, authToken, secretKey, gameId);
|
|
@@ -23,29 +15,93 @@ export class NetworkingPeerAxiosRequest extends NetworkingHttpPeerBase {
|
|
|
23
15
|
postRequest(subUri, param, postType, onHttpAppResponse, timeout, authToken, secretKey, customTags, gameId) {
|
|
24
16
|
this.postRequestAxios(subUri, param, postType, onHttpAppResponse, timeout, authToken, secretKey, customTags, gameId);
|
|
25
17
|
}
|
|
26
|
-
postRequestUpload(subUri, content, mimetype, onHttpAppResponse, timeout) {
|
|
27
|
-
GNDebug.logWarning("GN JS client sdk does not support upload file yet.");
|
|
18
|
+
postRequestUpload(subUri, content, filename, mimetype, onHttpAppResponse, timeout) {
|
|
19
|
+
//GNDebug.logWarning("GN JS client sdk does not support upload file yet.");
|
|
20
|
+
// let httpAppResponse = new HttpAppResponse();
|
|
21
|
+
// httpAppResponse.error = "Upload file does not support in GN JS client sdk.";
|
|
22
|
+
// httpAppResponse.statusCode = -1;
|
|
23
|
+
// httpAppResponse.text = "[-3]";
|
|
24
|
+
// if (onHttpAppResponse != null) onHttpAppResponse(httpAppResponse);
|
|
25
|
+
this.postRequestUploadAxios(subUri, content, filename, mimetype, onHttpAppResponse, timeout);
|
|
26
|
+
}
|
|
27
|
+
async getRequestAxios(subUri, onHttpAppResponse, timeout, authToken, secretKey, gameId) {
|
|
28
|
+
let headers = {};
|
|
29
|
+
if (authToken)
|
|
30
|
+
headers[Commands.RequestAuthTokenCmd] = authToken;
|
|
31
|
+
if (secretKey)
|
|
32
|
+
headers[Commands.RequestSecretCmd] = secretKey;
|
|
33
|
+
if (gameId)
|
|
34
|
+
headers[Commands.RequestGameIdCmd] = gameId;
|
|
35
|
+
if (!GNSupport.isBrowser())
|
|
36
|
+
headers[Commands.USER_AGENT] = this.userAgent;
|
|
28
37
|
let httpAppResponse = new HttpAppResponse();
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
38
|
+
try {
|
|
39
|
+
let result = await axios.get(this.httpUrl + "/" + subUri, {
|
|
40
|
+
headers: headers,
|
|
41
|
+
timeout: timeout * 1000,
|
|
42
|
+
responseType: "arraybuffer",
|
|
43
|
+
});
|
|
44
|
+
httpAppResponse.statusCode = result.status;
|
|
45
|
+
let buffers = this.toBuffers(result.data);
|
|
46
|
+
httpAppResponse.data = buffers[0];
|
|
47
|
+
httpAppResponse.text = buffers[1];
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
httpAppResponse.error = error.toString();
|
|
51
|
+
httpAppResponse.statusCode = -1;
|
|
52
|
+
httpAppResponse.text = "[-2]";
|
|
53
|
+
GNDebug.logError(error);
|
|
54
|
+
}
|
|
32
55
|
if (onHttpAppResponse != null)
|
|
33
56
|
onHttpAppResponse(httpAppResponse);
|
|
34
57
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
58
|
+
async postRequestAxios(subUri, param, postType, onHttpAppResponse, timeout, authToken, secretKey, customTags, gameId) {
|
|
59
|
+
let headers = {};
|
|
60
|
+
if (authToken)
|
|
61
|
+
headers[Commands.RequestAuthTokenCmd] = authToken;
|
|
62
|
+
if (secretKey)
|
|
63
|
+
headers[Commands.RequestSecretCmd] = secretKey;
|
|
64
|
+
if (gameId)
|
|
65
|
+
headers[Commands.RequestGameIdCmd] = gameId;
|
|
66
|
+
if (!GNSupport.isBrowser())
|
|
67
|
+
headers[Commands.USER_AGENT] = this.userAgent;
|
|
68
|
+
if (param == null)
|
|
69
|
+
param = new GNHashtable();
|
|
70
|
+
if (customTags != null)
|
|
71
|
+
param.add(GNParameterCode.CustomTags, customTags);
|
|
72
|
+
let body = null;
|
|
73
|
+
if (postType == PostType.Json) {
|
|
74
|
+
let content = param.toData();
|
|
75
|
+
body = content;
|
|
76
|
+
if (!GNSupport.isBrowser()) {
|
|
77
|
+
headers[Commands.CONTENT_LENGTH] = JSON.stringify(body).length;
|
|
78
|
+
headers[Commands.CONTENT_TYPE] = Commands.APPLICATION_JSON;
|
|
79
|
+
}
|
|
80
|
+
headers[Commands.ACCEPT] = Commands.APPLICATION_JSON;
|
|
81
|
+
}
|
|
82
|
+
else if (postType == PostType.MsgPack) {
|
|
83
|
+
let content = param.toData();
|
|
84
|
+
body = Buffer.from(MessagePackConverterService.serialize(content));
|
|
85
|
+
headers[Commands.CONTENT_TYPE] = Commands.APPLICATION_MSGPACK;
|
|
86
|
+
headers[Commands.ACCEPT] = Commands.APPLICATION_MSGPACK;
|
|
44
87
|
if (!GNSupport.isBrowser())
|
|
45
|
-
headers[Commands.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
88
|
+
headers[Commands.CONTENT_LENGTH] = body.length;
|
|
89
|
+
}
|
|
90
|
+
let httpAppResponse = new HttpAppResponse();
|
|
91
|
+
try {
|
|
92
|
+
if (postType == PostType.Json) {
|
|
93
|
+
let result = await axios.post(this.httpUrl + "/" + subUri, body, {
|
|
94
|
+
headers: headers,
|
|
95
|
+
timeout: timeout * 1000,
|
|
96
|
+
responseType: "text",
|
|
97
|
+
});
|
|
98
|
+
httpAppResponse.statusCode = result.status;
|
|
99
|
+
// let buffers = this.toBuffers(result.data);
|
|
100
|
+
// httpAppResponse.data = buffers[0];
|
|
101
|
+
httpAppResponse.text = result.data;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
let result = await axios.post(this.httpUrl + "/" + subUri, body, {
|
|
49
105
|
headers: headers,
|
|
50
106
|
timeout: timeout * 1000,
|
|
51
107
|
responseType: "arraybuffer",
|
|
@@ -55,83 +111,45 @@ export class NetworkingPeerAxiosRequest extends NetworkingHttpPeerBase {
|
|
|
55
111
|
httpAppResponse.data = buffers[0];
|
|
56
112
|
httpAppResponse.text = buffers[1];
|
|
57
113
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
httpAppResponse.error = error.toString();
|
|
117
|
+
httpAppResponse.statusCode = -1;
|
|
118
|
+
httpAppResponse.text = "[-2]";
|
|
119
|
+
GNDebug.logError(error);
|
|
120
|
+
}
|
|
121
|
+
if (onHttpAppResponse != null)
|
|
122
|
+
onHttpAppResponse(httpAppResponse);
|
|
67
123
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
headers[Commands.ACCEPT] = Commands.APPLICATION_MSGPACK;
|
|
98
|
-
if (!GNSupport.isBrowser())
|
|
99
|
-
headers[Commands.CONTENT_LENGTH] = body.length;
|
|
100
|
-
}
|
|
101
|
-
let httpAppResponse = new HttpAppResponse();
|
|
102
|
-
try {
|
|
103
|
-
if (postType == PostType.Json) {
|
|
104
|
-
let result = yield axios.post(this.httpUrl + "/" + subUri, body, {
|
|
105
|
-
headers: headers,
|
|
106
|
-
timeout: timeout * 1000,
|
|
107
|
-
responseType: "text",
|
|
108
|
-
});
|
|
109
|
-
httpAppResponse.statusCode = result.status;
|
|
110
|
-
// let buffers = this.toBuffers(result.data);
|
|
111
|
-
// httpAppResponse.data = buffers[0];
|
|
112
|
-
httpAppResponse.text = result.data;
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
let result = yield axios.post(this.httpUrl + "/" + subUri, body, {
|
|
116
|
-
headers: headers,
|
|
117
|
-
timeout: timeout * 1000,
|
|
118
|
-
responseType: "arraybuffer",
|
|
119
|
-
});
|
|
120
|
-
httpAppResponse.statusCode = result.status;
|
|
121
|
-
let buffers = this.toBuffers(result.data);
|
|
122
|
-
httpAppResponse.data = buffers[0];
|
|
123
|
-
httpAppResponse.text = buffers[1];
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
catch (error) {
|
|
127
|
-
httpAppResponse.error = error.toString();
|
|
128
|
-
httpAppResponse.statusCode = -1;
|
|
129
|
-
httpAppResponse.text = "[-2]";
|
|
130
|
-
GNDebug.logError(error);
|
|
131
|
-
}
|
|
132
|
-
if (onHttpAppResponse != null)
|
|
133
|
-
onHttpAppResponse(httpAppResponse);
|
|
134
|
-
});
|
|
124
|
+
async postRequestUploadAxios(subUri, content, filename, mimetype, onHttpAppResponse, timeout) {
|
|
125
|
+
let formData = new FormData();
|
|
126
|
+
formData.append(Commands.File, new Blob([content], { type: mimetype }), filename);
|
|
127
|
+
let headers = {};
|
|
128
|
+
headers[Commands.RequestAuthTokenCmd] = GNNetwork.getAuthenticateStatus().getAuthToken();
|
|
129
|
+
;
|
|
130
|
+
// if (!GNSupport.isBrowser()) {
|
|
131
|
+
// headers[Commands.CONTENT_TYPE] = "multipart/form-data";
|
|
132
|
+
// }
|
|
133
|
+
let httpAppResponse = new HttpAppResponse();
|
|
134
|
+
try {
|
|
135
|
+
let result = await axios.post(this.httpUrl + "/" + subUri, formData, {
|
|
136
|
+
headers: headers,
|
|
137
|
+
timeout: timeout * 1000,
|
|
138
|
+
responseType: "arraybuffer",
|
|
139
|
+
});
|
|
140
|
+
httpAppResponse.statusCode = result.status;
|
|
141
|
+
let buffers = this.toBuffers(result.data);
|
|
142
|
+
httpAppResponse.data = buffers[0];
|
|
143
|
+
httpAppResponse.text = buffers[1];
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
httpAppResponse.error = error.toString();
|
|
147
|
+
httpAppResponse.statusCode = -1;
|
|
148
|
+
httpAppResponse.text = "[-2]";
|
|
149
|
+
GNDebug.logError(error);
|
|
150
|
+
}
|
|
151
|
+
if (onHttpAppResponse != null)
|
|
152
|
+
onHttpAppResponse(httpAppResponse);
|
|
135
153
|
}
|
|
136
154
|
uint8ArrayToString(uint8Array) {
|
|
137
155
|
return decodeURIComponent(escape(String.fromCharCode(...uint8Array)));
|
|
@@ -8,7 +8,6 @@ export declare class NetworkingPeerSocketIOClient extends NetworkingSocketPeerBa
|
|
|
8
8
|
private socketManager;
|
|
9
9
|
private socket;
|
|
10
10
|
private isConnected;
|
|
11
|
-
isWsConnected: boolean;
|
|
12
11
|
sendRequestAuthSocket(): void;
|
|
13
12
|
reInitNewSocket(): void;
|
|
14
13
|
private onResponseMsgPack;
|
|
@@ -4,8 +4,8 @@ import { NetworkingSocketPeerBase, SocketPacket } from "./NetworkingSocketPeerBa
|
|
|
4
4
|
import { GNNetwork } from "./../../GNNetwork";
|
|
5
5
|
import { OperationHelper } from "./../../entity/OperationHelper";
|
|
6
6
|
import { Manager } from "socket.io-client";
|
|
7
|
-
import { encode } from "@msgpack/msgpack";
|
|
8
7
|
import { GNParameterCode } from "./../../constant/parameterCode/GNParameterCode";
|
|
8
|
+
import { MessagePackConverterService } from "./../../helper/MessagePackConverterService";
|
|
9
9
|
export class NetworkingPeerSocketIOClient extends NetworkingSocketPeerBase {
|
|
10
10
|
sendRequestAuthSocket() {
|
|
11
11
|
super.sendRequestAuthSocket();
|
|
@@ -92,7 +92,7 @@ export class NetworkingPeerSocketIOClient extends NetworkingSocketPeerBase {
|
|
|
92
92
|
operationRequest.setParameter(GNParameterCode.CustomTags, customTags);
|
|
93
93
|
let dataSend = OperationHelper.toSocketData(requestType, requestRole, operationRequest);
|
|
94
94
|
if (operationRequest.isEncrypted())
|
|
95
|
-
socket.emit(Commands.RequestCmd_MsgPack,
|
|
95
|
+
socket.emit(Commands.RequestCmd_MsgPack, MessagePackConverterService.serialize(dataSend));
|
|
96
96
|
else
|
|
97
97
|
socket.emit(Commands.RequestCmd_Json, dataSend);
|
|
98
98
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { MessagePackConverterService } from "./../../helper/MessagePackConverterService";
|
|
1
2
|
import { GNArray } from "./../../common/GNData";
|
|
2
3
|
import { GNNetwork } from "./../../GNNetwork";
|
|
3
4
|
import { GNDebug } from "./../../logger/GNDebug";
|
|
4
|
-
import { decode } from "@msgpack/msgpack";
|
|
5
5
|
export class SocketPacket {
|
|
6
6
|
constructor(obj, encrypted) {
|
|
7
7
|
this.obj = obj;
|
|
@@ -117,7 +117,7 @@ export class NetworkingSocketPeerBase {
|
|
|
117
117
|
let responsePacket = this.responsePacketLst[i];
|
|
118
118
|
if (responsePacket.encrypted) {
|
|
119
119
|
try {
|
|
120
|
-
let iList =
|
|
120
|
+
let iList = MessagePackConverterService.deserialize(responsePacket.obj);
|
|
121
121
|
let gnArray = GNArray.builder()
|
|
122
122
|
.addAll(NetworkingSocketPeerBase.fromMsgList(iList))
|
|
123
123
|
.build();
|
|
@@ -147,7 +147,7 @@ export class NetworkingSocketPeerBase {
|
|
|
147
147
|
let eventPacket = this.eventPacketLst[i];
|
|
148
148
|
if (eventPacket.encrypted) {
|
|
149
149
|
try {
|
|
150
|
-
let iList =
|
|
150
|
+
let iList = MessagePackConverterService.deserialize(eventPacket.obj);
|
|
151
151
|
let gnArray = GNArray.builder()
|
|
152
152
|
.addAll(NetworkingSocketPeerBase.fromMsgList(iList))
|
|
153
153
|
.build();
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xmobitea/gn-typescript-client",
|
|
3
|
-
"version": "2.5.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "2.5.3-esnext",
|
|
4
|
+
"description": "GearN Typescript Client SDK by XmobiTea (Pro)",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"dev": "rm -rf ./dist && npm run buildnode && npm run debug",
|
|
9
9
|
"debug": "node index.js",
|
|
10
10
|
"test": "mocha -r ts-node/register ./test/**/*.test.ts",
|
|
11
|
-
"buildnode": "webpack --config webpack.config.
|
|
12
|
-
"buildudm": "webpack --config webpack.config.udm.
|
|
13
|
-
"buildminudm": "webpack --config webpack.config.min.udm.
|
|
11
|
+
"buildnode": "webpack --config webpack.config.mjs --mode production --stats-modules",
|
|
12
|
+
"buildudm": "webpack --config webpack.config.udm.mjs --mode production --stats-modules",
|
|
13
|
+
"buildminudm": "webpack --config webpack.config.min.udm.mjs --mode production --stats-modules",
|
|
14
14
|
"build": "rm -rf ./dist && npm run buildnode && npm run buildudm && npm run buildminudm",
|
|
15
15
|
"build:withoutwebpack": "rm -rf ./dist && tsc",
|
|
16
16
|
"push": "npm run build && npm publish && git push"
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"license": "ISC",
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/mocha": "^10.0.10",
|
|
22
|
+
"@types/node": "^22.15.17",
|
|
22
23
|
"@types/store": "^2.0.5",
|
|
23
24
|
"mocha": "^11.0.1",
|
|
24
25
|
"terser-webpack-plugin": "^5.3.10",
|
|
@@ -40,4 +41,4 @@
|
|
|
40
41
|
"directories": {
|
|
41
42
|
"test": "test"
|
|
42
43
|
}
|
|
43
|
-
}
|
|
44
|
+
}
|