@xmobitea/gn-server 2.4.16 → 2.5.1
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/characterPlayer/SetDisplayNameRequestHandler.d.ts +1 -0
- package/dist/GN-app-api/handler/controller/handler/content/SetContentDataRequestHandler.d.ts +2 -0
- package/dist/GN-app-api/handler/controller/handler/dashboard/DeleteInDatabaseRequestHandler.d.ts +1 -0
- package/dist/GN-app-api/handler/controller/handler/dashboard/GrantGameRequestHandler.d.ts +2 -0
- package/dist/GN-app-api/handler/controller/handler/dashboard/SetMasterGameSettingsRequestHandler.d.ts +2 -0
- 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/gamePlayer/GrantPlayerCharacterRequestHandler.d.ts +1 -0
- 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-app-api/service/CacheService.d.ts +36 -0
- package/dist/GN-app-api/service/CloudScriptService.d.ts +2 -0
- package/dist/GN-app-api/service/ConfigService.d.ts +14 -0
- package/dist/{GN-library/xmail/lib/xMail.d.ts → GN-app-api/service/EmailService.d.ts} +3 -10
- package/dist/GN-app-api/service/EventCallbackService.d.ts +1 -0
- package/dist/GN-app-api/service/ICacheService.d.ts +15 -0
- package/dist/GN-app-api/service/IConfigService.d.ts +15 -0
- package/dist/GN-app-api/service/IEmailService.d.ts +10 -0
- package/dist/GN-app-api/service/IPushNotificationService.d.ts +17 -2
- package/dist/{GN-library/xnotification/lib/xPushNotification.d.ts → GN-app-api/service/PushNotificationService.d.ts} +8 -13
- package/dist/GN-common/constant/OperationCode.d.ts +2 -0
- package/dist/GN-common/constant/enumType/OwnerType.d.ts +2 -1
- 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/UploadFileInfo.d.ts +4 -2
- package/dist/GN-library/xdatabase/lib/entity/pro/findOptions/FileUploadInfoFindOptions.d.ts +9 -0
- package/dist/GN-library/xdatabase/lib/entity/pro/findOptions/StoreInventoryFindOptions.d.ts +1 -0
- package/dist/GN-library/xdatabase/lib/xDatabase.d.ts +15 -1
- package/dist/GN-startup/DefaultApplicationStartup.d.ts +2 -1
- package/dist/GN-startup/HttpApp.d.ts +6 -0
- package/dist/GN-startup/ServerApplication.d.ts +4 -0
- package/dist/GN-startup/cloudScript/eventCallbackCloudScriptData.json +20 -5
- package/dist/GN-startup/cloudScript/templateCloudScript.ts +203 -165
- package/dist/GN-startup/cloudScript/templateEventCallback.ts +263 -225
- package/dist/GN-startup/routes/ClusterHandler.d.ts +34 -0
- package/dist/GN-startup/routes/UploadFileHandler.d.ts +1 -0
- package/dist/GN-startup/settings/ApplicationSettings.d.ts +3 -0
- package/dist/GN-startup/settings/ClusterSettings.d.ts +29 -0
- package/dist/GNServer.d.ts +16 -13
- package/dist/index.d.ts +20 -14
- package/dist/index.js +74426 -82363
- package/gn.sh +19 -7
- package/package.json +4 -7
- package/dist/GN-library/xcachedata/lib/xCacheData.d.ts +0 -10
- package/dist/GN-library/xcachedata/lib/xCacheItem.d.ts +0 -8
- package/dist/GN-library/xconfig/lib/entity/xConfigItem.d.ts +0 -9
- package/dist/GN-library/xconfig/lib/xConfig.d.ts +0 -15
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { parentPort, workerData } from "worker_threads";
|
|
2
|
-
|
|
3
1
|
import { SecretInfo, SecretPermissionItem } from "../../index";
|
|
4
2
|
import { AuthInfo } from "../../index";
|
|
5
3
|
import { authenticate_InfoRequestParam as authenticate_InfoRequestParam } from "../../index";
|
|
@@ -138,12 +136,14 @@ import {
|
|
|
138
136
|
GroupStatus,
|
|
139
137
|
GNDebug,
|
|
140
138
|
ItemType,
|
|
139
|
+
StoreItemType,
|
|
141
140
|
LogType,
|
|
142
141
|
GNSupport,
|
|
143
142
|
PostType,
|
|
144
143
|
GetAuthInfoResponse,
|
|
145
144
|
PushPlatformType,
|
|
146
145
|
StoreReceiveType,
|
|
146
|
+
GNUtils,
|
|
147
147
|
} from "@xmobitea/gn-typescript-client";
|
|
148
148
|
|
|
149
149
|
import * as mongodb from "mongodb";
|
|
@@ -347,121 +347,160 @@ class CloudScriptSocket {
|
|
|
347
347
|
}
|
|
348
348
|
|
|
349
349
|
private async sendEvent(event: CloudScriptEvent) {
|
|
350
|
-
|
|
350
|
+
if (process?.send)
|
|
351
|
+
process.send(event);
|
|
351
352
|
}
|
|
352
353
|
}
|
|
353
354
|
|
|
354
355
|
class CloudScriptMatchmaking {
|
|
355
356
|
public async confirmServerDetail(gameId: string, matchmakingTicketCanMatch: MatchmakingTicketCanMatch, serverDetail: ServerDetail) {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
357
|
+
if (process?.send)
|
|
358
|
+
process.send({
|
|
359
|
+
eventType: 10,
|
|
360
|
+
receiver: null,
|
|
361
|
+
operationEvent: {
|
|
362
|
+
eventCode: 0,
|
|
363
|
+
encrypted: false,
|
|
364
|
+
parameters: {
|
|
365
|
+
gameId: gameId,
|
|
366
|
+
matchmakingTicketCanMatch: matchmakingTicketCanMatch,
|
|
367
|
+
serverDetail: serverDetail,
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
});
|
|
369
371
|
}
|
|
370
372
|
}
|
|
371
373
|
|
|
372
374
|
class CloudScriptMail {
|
|
373
375
|
public async send(email: string, subject: string, contentHtml: string) {
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
376
|
+
if (process?.send)
|
|
377
|
+
process.send({
|
|
378
|
+
eventType: 20,
|
|
379
|
+
receiver: null,
|
|
380
|
+
operationEvent: {
|
|
381
|
+
eventCode: 0,
|
|
382
|
+
encrypted: false,
|
|
383
|
+
parameters: {
|
|
384
|
+
email: email,
|
|
385
|
+
subject: subject,
|
|
386
|
+
contentHtml: contentHtml,
|
|
387
|
+
},
|
|
388
|
+
},
|
|
389
|
+
});
|
|
387
390
|
}
|
|
388
391
|
|
|
389
392
|
public async sendToMore(emails: string[], subject: string, contentHtml: string) {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
393
|
+
if (process?.send)
|
|
394
|
+
process.send({
|
|
395
|
+
eventType: 21,
|
|
396
|
+
receiver: null,
|
|
397
|
+
operationEvent: {
|
|
398
|
+
eventCode: 0,
|
|
399
|
+
encrypted: false,
|
|
400
|
+
parameters: {
|
|
401
|
+
emails: emails,
|
|
402
|
+
subject: subject,
|
|
403
|
+
contentHtml: contentHtml,
|
|
404
|
+
},
|
|
405
|
+
},
|
|
406
|
+
});
|
|
403
407
|
}
|
|
404
408
|
}
|
|
405
409
|
|
|
406
410
|
class CloudScriptPushNotification {
|
|
407
411
|
public async send(token: string, title: string, body: string, badge?: number, sound?: string, icon?: string, data?: { [k: string]: any }) {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
412
|
+
if (process?.send)
|
|
413
|
+
process.send({
|
|
414
|
+
eventType: 30,
|
|
415
|
+
receiver: null,
|
|
416
|
+
operationEvent: {
|
|
417
|
+
eventCode: 0,
|
|
418
|
+
encrypted: false,
|
|
419
|
+
parameters: {
|
|
420
|
+
token: token,
|
|
421
|
+
title: title,
|
|
422
|
+
body: body,
|
|
423
|
+
badge: badge,
|
|
424
|
+
sound: sound,
|
|
425
|
+
icon: icon,
|
|
426
|
+
data: data,
|
|
427
|
+
},
|
|
428
|
+
},
|
|
429
|
+
});
|
|
425
430
|
}
|
|
426
431
|
|
|
427
432
|
public async sendToMore(tokens: string[], title: string, body: string, badge?: number, sound?: string, icon?: string, data?: { [k: string]: any }) {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
433
|
+
if (process?.send)
|
|
434
|
+
process.send({
|
|
435
|
+
eventType: 31,
|
|
436
|
+
receiver: null,
|
|
437
|
+
operationEvent: {
|
|
438
|
+
eventCode: 0,
|
|
439
|
+
encrypted: false,
|
|
440
|
+
parameters: {
|
|
441
|
+
tokens: tokens,
|
|
442
|
+
title: title,
|
|
443
|
+
body: body,
|
|
444
|
+
badge: badge,
|
|
445
|
+
sound: sound,
|
|
446
|
+
icon: icon,
|
|
447
|
+
data: data,
|
|
448
|
+
},
|
|
449
|
+
},
|
|
450
|
+
});
|
|
445
451
|
}
|
|
446
452
|
|
|
447
453
|
public async sendToTopic(topic: string, title: string, body: string, badge?: number, sound?: string, icon?: string, data?: { [k: string]: any }) {
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
454
|
+
if (process?.send)
|
|
455
|
+
process.send({
|
|
456
|
+
eventType: 32,
|
|
457
|
+
receiver: null,
|
|
458
|
+
operationEvent: {
|
|
459
|
+
eventCode: 0,
|
|
460
|
+
encrypted: false,
|
|
461
|
+
parameters: {
|
|
462
|
+
topic: topic,
|
|
463
|
+
title: title,
|
|
464
|
+
body: body,
|
|
465
|
+
badge: badge,
|
|
466
|
+
sound: sound,
|
|
467
|
+
icon: icon,
|
|
468
|
+
data: data,
|
|
469
|
+
},
|
|
470
|
+
},
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
public async subscribeToTopic(tokens: string[], topic: string) {
|
|
475
|
+
if (process?.send)
|
|
476
|
+
process.send({
|
|
477
|
+
eventType: 33,
|
|
478
|
+
receiver: null,
|
|
479
|
+
operationEvent: {
|
|
480
|
+
eventCode: 0,
|
|
481
|
+
encrypted: false,
|
|
482
|
+
parameters: {
|
|
483
|
+
tokens: tokens,
|
|
484
|
+
topic: topic,
|
|
485
|
+
},
|
|
486
|
+
},
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
public async unsubscribeFromTopic(tokens: string[], topic: string) {
|
|
491
|
+
if (process?.send)
|
|
492
|
+
process.send({
|
|
493
|
+
eventType: 34,
|
|
494
|
+
receiver: null,
|
|
495
|
+
operationEvent: {
|
|
496
|
+
eventCode: 0,
|
|
497
|
+
encrypted: false,
|
|
498
|
+
parameters: {
|
|
499
|
+
tokens: tokens,
|
|
500
|
+
topic: topic,
|
|
501
|
+
},
|
|
502
|
+
},
|
|
503
|
+
});
|
|
465
504
|
}
|
|
466
505
|
}
|
|
467
506
|
|
|
@@ -541,146 +580,145 @@ interface FunctionResponse {
|
|
|
541
580
|
errorMessage: any;
|
|
542
581
|
}
|
|
543
582
|
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
let handleResponse: FunctionResponse = null as any;
|
|
552
|
-
|
|
553
|
-
if (request.eventType == EventCallbackType.System) {
|
|
554
|
-
if (request.eventName == "system_RequestServerDetail") {
|
|
555
|
-
let functionRequest: FunctionRequest = {
|
|
556
|
-
eventName: request.eventName,
|
|
557
|
-
operationRequest: null as any,
|
|
558
|
-
secretInfo: null as any,
|
|
559
|
-
request: request.request,
|
|
560
|
-
log(log: any) {
|
|
561
|
-
logs.push(JSON.stringify(log));
|
|
562
|
-
},
|
|
563
|
-
};
|
|
564
|
-
|
|
565
|
-
handleResponse = await ___handleMatchmakingFunction(functionRequest);
|
|
566
|
-
}
|
|
567
|
-
else {
|
|
568
|
-
let functionRequest: FunctionRequest = {
|
|
569
|
-
eventName: request.eventName,
|
|
570
|
-
operationRequest: null as any,
|
|
571
|
-
secretInfo: null as any,
|
|
572
|
-
request: null as any,
|
|
573
|
-
log(log: any) {
|
|
574
|
-
logs.push(JSON.stringify(log));
|
|
575
|
-
},
|
|
576
|
-
};
|
|
577
|
-
|
|
578
|
-
handleResponse = await ___handleSystemFunction(functionRequest);
|
|
579
|
-
}
|
|
580
|
-
} else if (request.eventType == EventCallbackType.Event) {
|
|
581
|
-
let originOperationEvent = request.operationRequest;
|
|
582
|
-
|
|
583
|
-
let operationEvent = new OperationEvent(originOperationEvent.operationCode, (originOperationEvent.parameters ? GNHashtable.builder().addAll(originOperationEvent.parameters).build() : null as any), originOperationEvent.encrypted);
|
|
583
|
+
process?.on("message", async (request: CloudScriptRequest) => {
|
|
584
|
+
let startTime = performance.now();
|
|
585
|
+
let startMemoryUsage = process.memoryUsage();
|
|
586
|
+
|
|
587
|
+
let logs: string[] = [];
|
|
588
|
+
|
|
589
|
+
let handleResponse: FunctionResponse = null as any;
|
|
584
590
|
|
|
591
|
+
if (request.eventType == EventCallbackType.System) {
|
|
592
|
+
if (request.eventName == "system_RequestServerDetail") {
|
|
585
593
|
let functionRequest: FunctionRequest = {
|
|
586
594
|
eventName: request.eventName,
|
|
587
595
|
operationRequest: null as any,
|
|
588
596
|
secretInfo: null as any,
|
|
589
|
-
request:
|
|
590
|
-
|
|
591
|
-
|
|
597
|
+
request: request.request,
|
|
598
|
+
log(log: any) {
|
|
599
|
+
logs.push(JSON.stringify(log));
|
|
592
600
|
},
|
|
601
|
+
};
|
|
602
|
+
|
|
603
|
+
handleResponse = await ___handleMatchmakingFunction(functionRequest);
|
|
604
|
+
}
|
|
605
|
+
else {
|
|
606
|
+
let functionRequest: FunctionRequest = {
|
|
607
|
+
eventName: request.eventName,
|
|
608
|
+
operationRequest: null as any,
|
|
609
|
+
secretInfo: null as any,
|
|
610
|
+
request: null as any,
|
|
593
611
|
log(log: any) {
|
|
594
612
|
logs.push(JSON.stringify(log));
|
|
595
613
|
},
|
|
596
614
|
};
|
|
597
615
|
|
|
598
|
-
handleResponse = await
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
.setIsOnlyMasterAdmin(originSecretInfo.onlyMasterAdmin)
|
|
618
|
-
.build();
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
if (request.eventType == EventCallbackType.Pre) {
|
|
622
|
-
let functionRequest: FunctionRequest = {
|
|
623
|
-
eventName: request.eventName,
|
|
624
|
-
operationRequest: operationRequest,
|
|
625
|
-
secretInfo: secretInfo,
|
|
626
|
-
request: request.request,
|
|
627
|
-
log(log: any) {
|
|
628
|
-
logs.push(JSON.stringify(log));
|
|
629
|
-
},
|
|
630
|
-
};
|
|
631
|
-
|
|
632
|
-
handleResponse = await ___handlePreFunction(functionRequest);
|
|
633
|
-
} else if (request.eventType == EventCallbackType.Post) {
|
|
634
|
-
let originOperationResponse = request.operationResponse;
|
|
635
|
-
let operationResponse: OperationResponse = null as any;
|
|
636
|
-
|
|
637
|
-
if (originOperationResponse) {
|
|
638
|
-
operationResponse = new OperationResponse(originOperationRequest.operationCode, originOperationRequest.requestId, originOperationRequest.encrypted);
|
|
639
|
-
operationResponse.setReturnCode(originOperationResponse.returnCode);
|
|
640
|
-
operationResponse.setDebugMessage(originOperationResponse.debugMessage);
|
|
641
|
-
|
|
642
|
-
if (originOperationResponse.parameters) {
|
|
643
|
-
operationResponse.setParameters(GNHashtable.builder().addAll(originOperationResponse.parameters).build());
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
let functionRequest: FunctionRequest = {
|
|
648
|
-
eventName: request.eventName,
|
|
649
|
-
operationRequest: operationRequest,
|
|
650
|
-
operationResponse: operationResponse,
|
|
651
|
-
secretInfo: secretInfo,
|
|
652
|
-
request: request.request,
|
|
653
|
-
log(log: any) {
|
|
654
|
-
logs.push(JSON.stringify(log));
|
|
655
|
-
},
|
|
656
|
-
};
|
|
657
|
-
|
|
658
|
-
handleResponse = await ___handlePostFunction(functionRequest);
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
let endTime = performance.now();
|
|
663
|
-
let endMemoryUsage = process.memoryUsage();
|
|
664
|
-
|
|
665
|
-
let memoryUsedInBytes = endMemoryUsage.heapUsed - startMemoryUsage.heapUsed;
|
|
666
|
-
if (memoryUsedInBytes <= 0) memoryUsedInBytes = 8192;
|
|
667
|
-
let executeTimeInMs = endTime - startTime;
|
|
668
|
-
|
|
669
|
-
//let cost = (memoryUsedInGb * executeTime) / 1000 * 0.022;
|
|
670
|
-
|
|
671
|
-
let response: CloudScriptResponse = {
|
|
672
|
-
responseId: request.requestId,
|
|
673
|
-
response: handleResponse as any,
|
|
674
|
-
stats: {
|
|
675
|
-
executeTimeInMs: executeTimeInMs,
|
|
676
|
-
memoryUsedInBytes: memoryUsedInBytes,
|
|
677
|
-
},
|
|
678
|
-
logs: logs,
|
|
679
|
-
};
|
|
616
|
+
handleResponse = await ___handleSystemFunction(functionRequest);
|
|
617
|
+
}
|
|
618
|
+
} else if (request.eventType == EventCallbackType.Event) {
|
|
619
|
+
let originOperationEvent = request.operationRequest;
|
|
620
|
+
|
|
621
|
+
let operationEvent = new OperationEvent(originOperationEvent.operationCode, (originOperationEvent.parameters ? GNHashtable.builder().addAll(originOperationEvent.parameters).build() : null as any), originOperationEvent.encrypted);
|
|
622
|
+
|
|
623
|
+
let functionRequest: FunctionRequest = {
|
|
624
|
+
eventName: request.eventName,
|
|
625
|
+
operationRequest: null as any,
|
|
626
|
+
secretInfo: null as any,
|
|
627
|
+
request: {
|
|
628
|
+
operationEvent: operationEvent,
|
|
629
|
+
request: request.request,
|
|
630
|
+
},
|
|
631
|
+
log(log: any) {
|
|
632
|
+
logs.push(JSON.stringify(log));
|
|
633
|
+
},
|
|
634
|
+
};
|
|
680
635
|
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
636
|
+
handleResponse = await ___handleEventFunction(functionRequest);
|
|
637
|
+
} else {
|
|
638
|
+
let originOperationRequest = request.operationRequest;
|
|
639
|
+
let operationRequest = new OperationRequest(originOperationRequest.operationCode, originOperationRequest.encrypted);
|
|
640
|
+
if (originOperationRequest.parameters) {
|
|
641
|
+
operationRequest.setParameters(GNHashtable.builder().addAll(originOperationRequest.parameters).build());
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
let originSecretInfo = request.secretInfo;
|
|
645
|
+
let secretInfo: SecretInfo = null as any;
|
|
646
|
+
if (originSecretInfo) {
|
|
647
|
+
secretInfo = SecretInfo.Builder()
|
|
648
|
+
.setSecretKey(originSecretInfo.secretKey)
|
|
649
|
+
.setRole(originSecretInfo.role)
|
|
650
|
+
.setIsRemove(originSecretInfo.remove)
|
|
651
|
+
.setTsExpire(originSecretInfo.tsExpire)
|
|
652
|
+
.setPermission(originSecretInfo.permission)
|
|
653
|
+
.setGameId(originSecretInfo.gameId)
|
|
654
|
+
.setIsDefault(originSecretInfo.isDefault)
|
|
655
|
+
.setIsOnlyMasterAdmin(originSecretInfo.onlyMasterAdmin)
|
|
656
|
+
.build();
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
if (request.eventType == EventCallbackType.Pre) {
|
|
660
|
+
let functionRequest: FunctionRequest = {
|
|
661
|
+
eventName: request.eventName,
|
|
662
|
+
operationRequest: operationRequest,
|
|
663
|
+
secretInfo: secretInfo,
|
|
664
|
+
request: request.request,
|
|
665
|
+
log(log: any) {
|
|
666
|
+
logs.push(JSON.stringify(log));
|
|
667
|
+
},
|
|
668
|
+
};
|
|
669
|
+
|
|
670
|
+
handleResponse = await ___handlePreFunction(functionRequest);
|
|
671
|
+
} else if (request.eventType == EventCallbackType.Post) {
|
|
672
|
+
let originOperationResponse = request.operationResponse;
|
|
673
|
+
let operationResponse: OperationResponse = null as any;
|
|
674
|
+
|
|
675
|
+
if (originOperationResponse) {
|
|
676
|
+
operationResponse = new OperationResponse(originOperationRequest.operationCode, originOperationRequest.requestId, originOperationRequest.encrypted);
|
|
677
|
+
operationResponse.setReturnCode(originOperationResponse.returnCode);
|
|
678
|
+
operationResponse.setDebugMessage(originOperationResponse.debugMessage);
|
|
679
|
+
|
|
680
|
+
if (originOperationResponse.parameters) {
|
|
681
|
+
operationResponse.setParameters(GNHashtable.builder().addAll(originOperationResponse.parameters).build());
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
let functionRequest: FunctionRequest = {
|
|
686
|
+
eventName: request.eventName,
|
|
687
|
+
operationRequest: operationRequest,
|
|
688
|
+
operationResponse: operationResponse,
|
|
689
|
+
secretInfo: secretInfo,
|
|
690
|
+
request: request.request,
|
|
691
|
+
log(log: any) {
|
|
692
|
+
logs.push(JSON.stringify(log));
|
|
693
|
+
},
|
|
694
|
+
};
|
|
695
|
+
|
|
696
|
+
handleResponse = await ___handlePostFunction(functionRequest);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
let endTime = performance.now();
|
|
701
|
+
let endMemoryUsage = process.memoryUsage();
|
|
702
|
+
|
|
703
|
+
let memoryUsedInBytes = endMemoryUsage.heapUsed - startMemoryUsage.heapUsed;
|
|
704
|
+
if (memoryUsedInBytes <= 0) memoryUsedInBytes = 8192;
|
|
705
|
+
let executeTimeInMs = endTime - startTime;
|
|
706
|
+
|
|
707
|
+
//let cost = (memoryUsedInGb * executeTime) / 1000 * 0.022;
|
|
708
|
+
|
|
709
|
+
let response: CloudScriptResponse = {
|
|
710
|
+
responseId: request.requestId,
|
|
711
|
+
response: handleResponse as any,
|
|
712
|
+
stats: {
|
|
713
|
+
executeTimeInMs: executeTimeInMs,
|
|
714
|
+
memoryUsedInBytes: memoryUsedInBytes,
|
|
715
|
+
},
|
|
716
|
+
logs: logs,
|
|
717
|
+
};
|
|
718
|
+
|
|
719
|
+
if (process?.send)
|
|
720
|
+
process.send(response);
|
|
721
|
+
});
|
|
684
722
|
|
|
685
723
|
async function ___handleMatchmakingFunction(request: FunctionRequest): Promise<FunctionResponse> {
|
|
686
724
|
let handler = systemMatchmakingHandlers[request.eventName];
|
|
@@ -859,7 +897,7 @@ async function ___handlePostFunction(request: FunctionRequest): Promise<Function
|
|
|
859
897
|
}
|
|
860
898
|
|
|
861
899
|
{
|
|
862
|
-
let gnServerSettingsOptions: GNServerSettingsOptions =
|
|
900
|
+
let gnServerSettingsOptions: GNServerSettingsOptions = JSON.parse(process.env.gnServerSettingsOptions ?? "");
|
|
863
901
|
|
|
864
902
|
let gnServerSettings = new GNServerSettings();
|
|
865
903
|
gnServerSettings.config(gnServerSettingsOptions);
|
|
@@ -876,12 +914,12 @@ const mail = new CloudScriptMail();
|
|
|
876
914
|
const pushNotification = new CloudScriptPushNotification();
|
|
877
915
|
|
|
878
916
|
{
|
|
879
|
-
let dbConnection =
|
|
917
|
+
let dbConnection = JSON.parse(process.env.dbConnection ?? "");
|
|
880
918
|
database.init(dbConnection.url, dbConnection.dbName, dbConnection.options);
|
|
881
919
|
}
|
|
882
920
|
|
|
883
|
-
|
|
884
|
-
|
|
921
|
+
process.env.dbConnection = "";
|
|
922
|
+
process.env.gnServerSettingsOptions = "";
|
|
885
923
|
|
|
886
924
|
const preHandlers: Record<string, (request: any, secretInfo: SecretInfo, operationRequest: OperationRequest, log: (log: any) => void) => Promise<OperationResponse | null>> = {};
|
|
887
925
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import express from "express";
|
|
2
|
+
interface NodeInfo {
|
|
3
|
+
instanceId: string;
|
|
4
|
+
fullUrl: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class ClusterHandler {
|
|
7
|
+
private router;
|
|
8
|
+
private clusterRouter;
|
|
9
|
+
private instanceId;
|
|
10
|
+
private isPrimary;
|
|
11
|
+
private privateKeyToken;
|
|
12
|
+
private allNodes;
|
|
13
|
+
private instanceInfoStatus;
|
|
14
|
+
private instanceInfos;
|
|
15
|
+
private onEventCallback;
|
|
16
|
+
private isSingleNode;
|
|
17
|
+
setRouter(router: express.Express): void;
|
|
18
|
+
setInstanceId(instanceId: string): void;
|
|
19
|
+
setIsPrimary(isPrimary: boolean): void;
|
|
20
|
+
getIsPrimary(): boolean;
|
|
21
|
+
getIsSingleNode(): boolean;
|
|
22
|
+
setPrivateKeyToken(privateKeyToken: string): void;
|
|
23
|
+
setAllNodes(allNodes: NodeInfo[]): void;
|
|
24
|
+
init(): void;
|
|
25
|
+
run(): void;
|
|
26
|
+
private callbackInvoke;
|
|
27
|
+
private update;
|
|
28
|
+
private checkInstanceStatus;
|
|
29
|
+
private checkInstancePrimary;
|
|
30
|
+
onEvent(name: string, onData: (data: any) => void): void;
|
|
31
|
+
sendEvent(name: string, data?: any, includeMe?: boolean): Promise<void>;
|
|
32
|
+
constructor();
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { IBuilder } from "./../../GN-library/xbuilder/lib/IBuilder";
|
|
2
2
|
declare abstract class BuilderBase {
|
|
3
3
|
protected port: number;
|
|
4
|
+
protected socketPort: number;
|
|
4
5
|
protected useSSL: boolean;
|
|
5
6
|
protected keyFilePath: string;
|
|
6
7
|
protected certFilePath: string;
|
|
7
8
|
protected expiredToken: number;
|
|
8
9
|
protected privateKeyToken: string;
|
|
9
10
|
getPort(): number;
|
|
11
|
+
getSocketPort(): number;
|
|
10
12
|
getUseSSL(): boolean;
|
|
11
13
|
getKeyFilePath(): string;
|
|
12
14
|
getCertFilePath(): string;
|
|
@@ -16,6 +18,7 @@ declare abstract class BuilderBase {
|
|
|
16
18
|
}
|
|
17
19
|
declare class Builder extends BuilderBase implements IBuilder<ApplicationSettings> {
|
|
18
20
|
setPort(port: number): Builder;
|
|
21
|
+
setSocketPort(socketPort: number): Builder;
|
|
19
22
|
setUseSSL(useSSL: boolean): Builder;
|
|
20
23
|
setKeyFilePath(keyFilePath: string): Builder;
|
|
21
24
|
setCertFilePath(certFilePath: string): Builder;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { IBuilder } from "./../../GN-library/xbuilder/lib/IBuilder";
|
|
2
|
+
interface NodeInfo {
|
|
3
|
+
instanceId: string;
|
|
4
|
+
fullUrl: string;
|
|
5
|
+
}
|
|
6
|
+
declare abstract class BuilderBase {
|
|
7
|
+
protected instanceId: string;
|
|
8
|
+
protected isPrimary: boolean;
|
|
9
|
+
protected privateKeyToken: string;
|
|
10
|
+
protected allNodes: NodeInfo[];
|
|
11
|
+
getInstanceId(): string;
|
|
12
|
+
getIsPrimary(): boolean;
|
|
13
|
+
getPrivateKeyToken(): string;
|
|
14
|
+
getAllNodes(): NodeInfo[];
|
|
15
|
+
constructor();
|
|
16
|
+
}
|
|
17
|
+
declare class Builder extends BuilderBase implements IBuilder<ClusterSettings> {
|
|
18
|
+
setInstanceId(instanceId: string): Builder;
|
|
19
|
+
setIsPrimary(isPrimary: boolean): Builder;
|
|
20
|
+
setPrivateKeyToken(privateKeyToken: string): Builder;
|
|
21
|
+
setAllNodes(allNodes: NodeInfo[]): Builder;
|
|
22
|
+
constructor();
|
|
23
|
+
build(): ClusterSettings;
|
|
24
|
+
}
|
|
25
|
+
export declare class ClusterSettings extends BuilderBase {
|
|
26
|
+
constructor(builder: Builder);
|
|
27
|
+
static Builder(): Builder;
|
|
28
|
+
}
|
|
29
|
+
export {};
|