@xmobitea/gn-server 2.4.16 → 2.5.0
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/GN-app-api/handler/controller/handler/characterPlayer/GetCreateLeaderboardRequestHandler.d.ts +0 -1
- package/dist/GN-app-api/handler/controller/handler/characterPlayer/GetCurrencyLeaderboardRequestHandler.d.ts +0 -1
- package/dist/GN-app-api/handler/controller/handler/characterPlayer/GetCurrencyLogRequestHandler.d.ts +0 -1
- package/dist/GN-app-api/handler/controller/handler/characterPlayer/GetLastLoginLeaderboardRequestHandler.d.ts +22 -0
- package/dist/GN-app-api/handler/controller/handler/characterPlayer/GetStatisticsLeaderboardRequestHandler.d.ts +0 -1
- package/dist/GN-app-api/handler/controller/handler/characterPlayer/GetStatisticsLogRequestHandler.d.ts +0 -1
- package/dist/GN-app-api/handler/controller/handler/dashboard/model/CharacterPlayerPermissionRulesParam.d.ts +1 -0
- package/dist/GN-app-api/handler/controller/handler/dashboard/model/StoreInventoryPermissionRulesParam.d.ts +2 -0
- package/dist/GN-app-api/handler/controller/handler/gamePlayer/GetCurrencyLogRequestHandler.d.ts +0 -1
- package/dist/GN-app-api/handler/controller/handler/gamePlayer/GetStatisticsLogRequestHandler.d.ts +0 -1
- package/dist/GN-app-api/handler/controller/handler/group/GetCurrencyLogRequestHandler.d.ts +0 -1
- package/dist/GN-app-api/handler/controller/handler/group/GetStatisticsLogRequestHandler.d.ts +0 -1
- package/dist/GN-app-api/handler/controller/handler/inventory/GetStatisticsLogRequestHandler.d.ts +0 -1
- package/dist/GN-app-api/handler/controller/handler/masterPlayer/GetCurrencyLogRequestHandler.d.ts +0 -1
- package/dist/GN-app-api/handler/controller/handler/masterPlayer/GetStatisticsLogRequestHandler.d.ts +0 -1
- package/dist/GN-app-api/handler/controller/handler/storeInventory/GetStoreUsedRequestHandler.d.ts +17 -0
- package/dist/GN-app-api/handler/controller/handler/storeInventory/RemoveStoreUsedRequestHandler.d.ts +18 -0
- package/dist/GN-app-api/handler/controller/handler/storeInventory/SetStoreItemInformationRequestHandler.d.ts +1 -0
- package/dist/GN-app-api/handler/controller/handler/storeInventory/StoreItemBaseRequestHandler.d.ts +1 -0
- package/dist/GN-app-api/handler/controller/handler/storeInventory/model/InfoRequestParam.d.ts +1 -0
- package/dist/GN-common/constant/OperationCode.d.ts +2 -0
- package/dist/GN-common/constant/enumType/StoreItemType.d.ts +4 -0
- package/dist/GN-common/constant/errorCode/GNErrorCode.d.ts +2 -0
- package/dist/GN-common/constant/parameterCode/GNParameterCode.d.ts +4 -0
- package/dist/GN-common/entity/SecretInfo.d.ts +3 -0
- package/dist/GN-library/xdatabase/lib/entity/pro/StoreInventory.d.ts +4 -0
- package/dist/GN-library/xdatabase/lib/entity/pro/findOptions/StoreInventoryFindOptions.d.ts +1 -0
- package/dist/GN-library/xdatabase/lib/xDatabase.d.ts +12 -0
- package/dist/GN-startup/cloudScript/eventCallbackCloudScriptData.json +17 -2
- package/dist/GN-startup/cloudScript/templateCloudScript.ts +171 -165
- package/dist/GN-startup/cloudScript/templateEventCallback.ts +231 -225
- package/dist/GN-startup/settings/ApplicationSettings.d.ts +3 -0
- package/dist/GNServer.d.ts +4 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1177 -441
- package/gn.sh +2 -2
- package/package.json +2 -5
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { parentPort, workerData } from "worker_threads";
|
|
2
|
-
|
|
3
1
|
import {
|
|
4
2
|
GNNetwork,
|
|
5
3
|
Action0,
|
|
@@ -62,9 +60,14 @@ import {
|
|
|
62
60
|
GroupStatus,
|
|
63
61
|
GNDebug,
|
|
64
62
|
ItemType,
|
|
63
|
+
StoreItemType,
|
|
65
64
|
LogType,
|
|
66
65
|
GNSupport,
|
|
67
66
|
PostType,
|
|
67
|
+
GetAuthInfoResponse,
|
|
68
|
+
PushPlatformType,
|
|
69
|
+
StoreReceiveType,
|
|
70
|
+
GNUtils,
|
|
68
71
|
} from "@xmobitea/gn-typescript-client";
|
|
69
72
|
|
|
70
73
|
import * as mongodb from "mongodb";
|
|
@@ -268,103 +271,109 @@ class CloudScriptSocket {
|
|
|
268
271
|
}
|
|
269
272
|
|
|
270
273
|
private async sendEvent(event: CloudScriptEvent) {
|
|
271
|
-
|
|
274
|
+
if (process?.send)
|
|
275
|
+
process.send(event);
|
|
272
276
|
}
|
|
273
277
|
}
|
|
274
278
|
|
|
275
279
|
class CloudScriptMail {
|
|
276
280
|
public async send(email: string, subject: string, contentHtml: string) {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
281
|
+
if (process?.send)
|
|
282
|
+
process.send({
|
|
283
|
+
eventType: 20,
|
|
284
|
+
receiver: null,
|
|
285
|
+
operationEvent: {
|
|
286
|
+
eventCode: 0,
|
|
287
|
+
encrypted: false,
|
|
288
|
+
parameters: {
|
|
289
|
+
email: email,
|
|
290
|
+
subject: subject,
|
|
291
|
+
contentHtml: contentHtml,
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
});
|
|
290
295
|
}
|
|
291
296
|
|
|
292
297
|
public async sendToMore(emails: string[], subject: string, contentHtml: string) {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
298
|
+
if (process?.send)
|
|
299
|
+
process.send({
|
|
300
|
+
eventType: 21,
|
|
301
|
+
receiver: null,
|
|
302
|
+
operationEvent: {
|
|
303
|
+
eventCode: 0,
|
|
304
|
+
encrypted: false,
|
|
305
|
+
parameters: {
|
|
306
|
+
emails: emails,
|
|
307
|
+
subject: subject,
|
|
308
|
+
contentHtml: contentHtml,
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
});
|
|
306
312
|
}
|
|
307
313
|
}
|
|
308
314
|
|
|
309
315
|
class CloudScriptPushNotification {
|
|
310
316
|
public async send(token: string, title: string, body: string, badge?: number, sound?: string, icon?: string, data?: { [k: string]: any }) {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
317
|
+
if (process?.send)
|
|
318
|
+
process.send({
|
|
319
|
+
eventType: 30,
|
|
320
|
+
receiver: null,
|
|
321
|
+
operationEvent: {
|
|
322
|
+
eventCode: 0,
|
|
323
|
+
encrypted: false,
|
|
324
|
+
parameters: {
|
|
325
|
+
token: token,
|
|
326
|
+
title: title,
|
|
327
|
+
body: body,
|
|
328
|
+
badge: badge,
|
|
329
|
+
sound: sound,
|
|
330
|
+
icon: icon,
|
|
331
|
+
data: data,
|
|
332
|
+
},
|
|
333
|
+
},
|
|
334
|
+
});
|
|
328
335
|
}
|
|
329
336
|
|
|
330
337
|
public async sendToMore(tokens: string[], title: string, body: string, badge?: number, sound?: string, icon?: string, data?: { [k: string]: any }) {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
338
|
+
if (process?.send)
|
|
339
|
+
process.send({
|
|
340
|
+
eventType: 31,
|
|
341
|
+
receiver: null,
|
|
342
|
+
operationEvent: {
|
|
343
|
+
eventCode: 0,
|
|
344
|
+
encrypted: false,
|
|
345
|
+
parameters: {
|
|
346
|
+
tokens: tokens,
|
|
347
|
+
title: title,
|
|
348
|
+
body: body,
|
|
349
|
+
badge: badge,
|
|
350
|
+
sound: sound,
|
|
351
|
+
icon: icon,
|
|
352
|
+
data: data,
|
|
353
|
+
},
|
|
354
|
+
},
|
|
355
|
+
});
|
|
348
356
|
}
|
|
349
357
|
|
|
350
358
|
public async sendToTopic(topic: string, title: string, body: string, badge?: number, sound?: string, icon?: string, data?: { [k: string]: any }) {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
359
|
+
if (process?.send)
|
|
360
|
+
process.send({
|
|
361
|
+
eventType: 32,
|
|
362
|
+
receiver: null,
|
|
363
|
+
operationEvent: {
|
|
364
|
+
eventCode: 0,
|
|
365
|
+
encrypted: false,
|
|
366
|
+
parameters: {
|
|
367
|
+
topic: topic,
|
|
368
|
+
title: title,
|
|
369
|
+
body: body,
|
|
370
|
+
badge: badge,
|
|
371
|
+
sound: sound,
|
|
372
|
+
icon: icon,
|
|
373
|
+
data: data,
|
|
374
|
+
},
|
|
375
|
+
},
|
|
376
|
+
});
|
|
368
377
|
}
|
|
369
378
|
}
|
|
370
379
|
|
|
@@ -459,85 +468,84 @@ const ConvertArray = (results: any[]) => {
|
|
|
459
468
|
return answer;
|
|
460
469
|
}
|
|
461
470
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
};
|
|
478
|
-
|
|
479
|
-
let handleResponse = await ___handleFunction(functionRequest);
|
|
480
|
-
|
|
481
|
-
if (handleResponse.result) {
|
|
482
|
-
if (handleResponse.result instanceof GNHashtable) {
|
|
483
|
-
handleResponse.result = (<GNHashtable>handleResponse.result).toData();
|
|
484
|
-
}
|
|
485
|
-
else if (handleResponse.result instanceof GNArray) {
|
|
486
|
-
handleResponse.result = (<GNArray>handleResponse.result).toData();
|
|
487
|
-
}
|
|
488
|
-
else {
|
|
489
|
-
let typeofResult = typeof (handleResponse.result);
|
|
490
|
-
|
|
491
|
-
if (typeofResult == "boolean") {
|
|
492
|
-
|
|
493
|
-
}
|
|
494
|
-
else if (typeofResult == "number") {
|
|
495
|
-
|
|
496
|
-
}
|
|
497
|
-
else if (typeofResult == "object") {
|
|
498
|
-
if (Array.isArray(handleResponse.result)) {
|
|
499
|
-
|
|
500
|
-
handleResponse.result = ConvertArray(handleResponse.result as any[]);
|
|
501
|
-
//answer.push(this.deserializeArray(gnArray.getGNArray(i), cls));
|
|
502
|
-
}
|
|
503
|
-
else {
|
|
504
|
-
handleResponse.result = ConvertObject(handleResponse.result);
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
else if (typeofResult == "string") {
|
|
508
|
-
|
|
509
|
-
}
|
|
510
|
-
else {
|
|
511
|
-
handleResponse.result = null;
|
|
512
|
-
|
|
513
|
-
handleResponse.errorMessage = "CloudScript must return void, number, string, boolean, null, json dictionary, json array, GNHashtable or GNArray";
|
|
514
|
-
handleResponse.status = ExecuteResponseStatus.Exception;
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
let endTime = performance.now();
|
|
520
|
-
let endMemoryUsage = process.memoryUsage();
|
|
521
|
-
|
|
522
|
-
let memoryUsedInBytes = endMemoryUsage.heapUsed - startMemoryUsage.heapUsed;
|
|
523
|
-
if (memoryUsedInBytes <= 0) memoryUsedInBytes = 8192;
|
|
524
|
-
let executeTimeInMs = endTime - startTime;
|
|
525
|
-
|
|
526
|
-
//let cost = (memoryUsedInGb * executeTime) / 1000 * 0.022;
|
|
471
|
+
process?.on("message", async (request: CloudScriptRequest) => {
|
|
472
|
+
let startTime = performance.now();
|
|
473
|
+
let startMemoryUsage = process.memoryUsage();
|
|
474
|
+
|
|
475
|
+
let logs: string[] = [];
|
|
476
|
+
let functionRequest: FunctionRequest = {
|
|
477
|
+
userId: request.userId,
|
|
478
|
+
name: request.name,
|
|
479
|
+
parameters: request.parameters,
|
|
480
|
+
context: {},
|
|
481
|
+
customTags: request.customTags,
|
|
482
|
+
log(log: any) {
|
|
483
|
+
logs.push(JSON.stringify(log));
|
|
484
|
+
},
|
|
485
|
+
};
|
|
527
486
|
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
487
|
+
let handleResponse = await ___handleFunction(functionRequest);
|
|
488
|
+
|
|
489
|
+
if (handleResponse.result) {
|
|
490
|
+
if (handleResponse.result instanceof GNHashtable) {
|
|
491
|
+
handleResponse.result = (<GNHashtable>handleResponse.result).toData();
|
|
492
|
+
}
|
|
493
|
+
else if (handleResponse.result instanceof GNArray) {
|
|
494
|
+
handleResponse.result = (<GNArray>handleResponse.result).toData();
|
|
495
|
+
}
|
|
496
|
+
else {
|
|
497
|
+
let typeofResult = typeof (handleResponse.result);
|
|
498
|
+
|
|
499
|
+
if (typeofResult == "boolean") {
|
|
500
|
+
|
|
501
|
+
}
|
|
502
|
+
else if (typeofResult == "number") {
|
|
503
|
+
|
|
504
|
+
}
|
|
505
|
+
else if (typeofResult == "object") {
|
|
506
|
+
if (Array.isArray(handleResponse.result)) {
|
|
507
|
+
|
|
508
|
+
handleResponse.result = ConvertArray(handleResponse.result as any[]);
|
|
509
|
+
//answer.push(this.deserializeArray(gnArray.getGNArray(i), cls));
|
|
510
|
+
}
|
|
511
|
+
else {
|
|
512
|
+
handleResponse.result = ConvertObject(handleResponse.result);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
else if (typeofResult == "string") {
|
|
516
|
+
|
|
517
|
+
}
|
|
518
|
+
else {
|
|
519
|
+
handleResponse.result = null;
|
|
520
|
+
|
|
521
|
+
handleResponse.errorMessage = "CloudScript must return void, number, string, boolean, null, json dictionary, json array, GNHashtable or GNArray";
|
|
522
|
+
handleResponse.status = ExecuteResponseStatus.Exception;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
let endTime = performance.now();
|
|
528
|
+
let endMemoryUsage = process.memoryUsage();
|
|
529
|
+
|
|
530
|
+
let memoryUsedInBytes = endMemoryUsage.heapUsed - startMemoryUsage.heapUsed;
|
|
531
|
+
if (memoryUsedInBytes <= 0) memoryUsedInBytes = 8192;
|
|
532
|
+
let executeTimeInMs = endTime - startTime;
|
|
533
|
+
|
|
534
|
+
//let cost = (memoryUsedInGb * executeTime) / 1000 * 0.022;
|
|
535
|
+
|
|
536
|
+
let response: CloudScriptResponse = {
|
|
537
|
+
responseId: request.requestId,
|
|
538
|
+
response: handleResponse,
|
|
539
|
+
stats: {
|
|
540
|
+
executeTimeInMs: executeTimeInMs,
|
|
541
|
+
memoryUsedInBytes: memoryUsedInBytes,
|
|
542
|
+
},
|
|
543
|
+
logs: logs,
|
|
544
|
+
};
|
|
537
545
|
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
}
|
|
546
|
+
if (process?.send)
|
|
547
|
+
process.send(response);
|
|
548
|
+
});
|
|
541
549
|
|
|
542
550
|
async function ___handleFunction(request: FunctionRequest): Promise<FunctionResponse> {
|
|
543
551
|
let handler = handlers[request.name];
|
|
@@ -566,20 +574,18 @@ async function ___handleFunction(request: FunctionRequest): Promise<FunctionResp
|
|
|
566
574
|
return answer;
|
|
567
575
|
}
|
|
568
576
|
|
|
577
|
+
const gameId: string = process.env.gameId ?? "";
|
|
578
|
+
|
|
569
579
|
{
|
|
570
|
-
let gnServerSettingsOptions: GNServerSettingsOptions =
|
|
580
|
+
let gnServerSettingsOptions: GNServerSettingsOptions = JSON.parse(process.env.gnServerSettingsOptions ?? "");
|
|
571
581
|
|
|
572
582
|
let gnServerSettings = new GNServerSettings();
|
|
573
583
|
gnServerSettings.config(gnServerSettingsOptions);
|
|
574
584
|
|
|
575
585
|
GNNetwork.init(gnServerSettings);
|
|
576
|
-
|
|
577
|
-
let gameId = workerData.gameId;
|
|
578
586
|
GNNetwork.setGameId(gameId);
|
|
579
587
|
}
|
|
580
588
|
|
|
581
|
-
const gameId: string = workerData.gameId;
|
|
582
|
-
|
|
583
589
|
const admin = new CloudScriptAdmin();
|
|
584
590
|
const database = new CloudScriptDatabase();
|
|
585
591
|
const http = new CloudScriptHttp();
|
|
@@ -588,12 +594,12 @@ const mail = new CloudScriptMail();
|
|
|
588
594
|
const pushNotification = new CloudScriptPushNotification();
|
|
589
595
|
|
|
590
596
|
{
|
|
591
|
-
let dbConnection =
|
|
597
|
+
let dbConnection = JSON.parse(process.env.dbConnection ?? "");
|
|
592
598
|
database.init(dbConnection.url, dbConnection.dbName, dbConnection.options);
|
|
593
599
|
}
|
|
594
600
|
|
|
595
|
-
|
|
596
|
-
|
|
601
|
+
process.env.dbConnection = "";
|
|
602
|
+
process.env.gnServerSettingsOptions = "";
|
|
597
603
|
|
|
598
604
|
const handlers: Record<string, (args: any, context: { userId: string; customTags: { [k: string]: any } }, log: (log: any) => void) => any> = {};
|
|
599
605
|
|