@xmobitea/gn-server 2.0.6 → 2.1.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/cloudScript/AddFunctionRequestHandler.d.ts +20 -0
- package/dist/GN-app-api/handler/controller/handler/cloudScript/EditFunctionRequestHandler.d.ts +20 -0
- package/dist/GN-app-api/handler/controller/handler/cloudScript/ExecuteFunctionRequestHandler.d.ts +21 -0
- package/dist/GN-app-api/handler/controller/handler/cloudScript/GetFunctionRequestHandler.d.ts +18 -0
- package/dist/GN-app-api/handler/controller/handler/cloudScript/GetFunctionsRequestHandler.d.ts +17 -0
- package/dist/GN-app-api/handler/controller/handler/dashboard/GetSecretInfoInformationRequestHandler.d.ts +1 -1
- package/dist/GN-app-api/handler/controller/handler/dashboard/model/CloudScriptPermissionRulesParam.d.ts +8 -0
- package/dist/GN-app-api/handler/controller/handler/dashboard/model/PermissionParam.d.ts +2 -0
- package/dist/GN-app-api/handler/controller/handler/masterPlayer/ResetAccountPasswordRequestHandler.d.ts +1 -1
- package/dist/GN-app-api/handler/controller/handler/masterPlayer/SetAvatarRequestHandler.d.ts +1 -1
- package/dist/GN-app-api/service/CloudScriptService.d.ts +47 -0
- package/dist/GN-app-api/service/ICloudScriptService.d.ts +43 -0
- package/dist/GN-common/constant/OperationCode.d.ts +5 -0
- package/dist/GN-common/constant/enumType/RequestType.d.ts +2 -1
- package/dist/GN-common/constant/errorCode/GNErrorCode.d.ts +1 -0
- package/dist/GN-common/constant/parameterCode/GNParameterCode.d.ts +16 -0
- package/dist/GN-common/entity/DataMember.d.ts +1 -1
- package/dist/GN-common/entity/SecretInfo.d.ts +13 -0
- package/dist/GN-startup/SocketApp.d.ts +0 -1
- package/dist/GN-startup/cloudScript/template.ts +118 -0
- package/dist/GN-startup/routes/AdminAppHandler.d.ts +2 -1
- package/dist/GN-startup/routes/SocketAppHandler.d.ts +1 -1
- package/dist/GNServer.d.ts +3 -0
- package/dist/index.js +6178 -4836
- package/package.json +4 -3
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { OperationRequest } from "./../../../../../GN-common/entity/operationRequest/OperationRequest";
|
|
2
|
+
import { OperationResponse } from "./../../../../../GN-common/entity/operationResponse/OperationResponse";
|
|
3
|
+
import { AuthInfo } from "./../../../../../GN-common/entity/AuthInfo";
|
|
4
|
+
import { SecretInfo } from "./../../../../../GN-common/entity/SecretInfo";
|
|
5
|
+
import { RequestHandler } from "./../base/RequestHandler";
|
|
6
|
+
declare class AddFunctionOperationRequest extends OperationRequest {
|
|
7
|
+
script: string;
|
|
8
|
+
canExecute: boolean;
|
|
9
|
+
isLive: boolean;
|
|
10
|
+
isValidRequest(): boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare class AddFunctionRequestHandler extends RequestHandler {
|
|
13
|
+
getCode(): number;
|
|
14
|
+
getCommonOperationRequest(): typeof AddFunctionOperationRequest;
|
|
15
|
+
handle(authInfo: AuthInfo, secretInfo: SecretInfo, operationRequest: OperationRequest): Promise<OperationResponse>;
|
|
16
|
+
serverHandle(secretInfo: SecretInfo, operationRequest: OperationRequest): Promise<OperationResponse>;
|
|
17
|
+
adminHandle(secretInfo: SecretInfo, operationRequest: OperationRequest): Promise<OperationResponse>;
|
|
18
|
+
private execute;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
package/dist/GN-app-api/handler/controller/handler/cloudScript/EditFunctionRequestHandler.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { OperationRequest } from "./../../../../../GN-common/entity/operationRequest/OperationRequest";
|
|
2
|
+
import { OperationResponse } from "./../../../../../GN-common/entity/operationResponse/OperationResponse";
|
|
3
|
+
import { AuthInfo } from "./../../../../../GN-common/entity/AuthInfo";
|
|
4
|
+
import { SecretInfo } from "./../../../../../GN-common/entity/SecretInfo";
|
|
5
|
+
import { RequestHandler } from "./../base/RequestHandler";
|
|
6
|
+
declare class EditFunctionOperationRequest extends OperationRequest {
|
|
7
|
+
version: string;
|
|
8
|
+
canExecute: boolean;
|
|
9
|
+
isLive: boolean;
|
|
10
|
+
isValidRequest(): boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare class EditFunctionRequestHandler extends RequestHandler {
|
|
13
|
+
getCode(): number;
|
|
14
|
+
getCommonOperationRequest(): typeof EditFunctionOperationRequest;
|
|
15
|
+
handle(authInfo: AuthInfo, secretInfo: SecretInfo, operationRequest: OperationRequest): Promise<OperationResponse>;
|
|
16
|
+
serverHandle(secretInfo: SecretInfo, operationRequest: OperationRequest): Promise<OperationResponse>;
|
|
17
|
+
adminHandle(secretInfo: SecretInfo, operationRequest: OperationRequest): Promise<OperationResponse>;
|
|
18
|
+
private execute;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
package/dist/GN-app-api/handler/controller/handler/cloudScript/ExecuteFunctionRequestHandler.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { OperationRequest } from "./../../../../../GN-common/entity/operationRequest/OperationRequest";
|
|
2
|
+
import { OperationResponse } from "./../../../../../GN-common/entity/operationResponse/OperationResponse";
|
|
3
|
+
import { AuthInfo } from "./../../../../../GN-common/entity/AuthInfo";
|
|
4
|
+
import { SecretInfo } from "./../../../../../GN-common/entity/SecretInfo";
|
|
5
|
+
import { RequestHandler } from "./../base/RequestHandler";
|
|
6
|
+
declare class ExecuteFunctionOperationRequest extends OperationRequest {
|
|
7
|
+
userId?: string;
|
|
8
|
+
functionName: string;
|
|
9
|
+
functionParameter?: object;
|
|
10
|
+
version: string;
|
|
11
|
+
isValidRequest(): boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare class ExecuteFunctionRequestHandler extends RequestHandler {
|
|
14
|
+
getCode(): number;
|
|
15
|
+
getCommonOperationRequest(): typeof ExecuteFunctionOperationRequest;
|
|
16
|
+
handle(authInfo: AuthInfo, secretInfo: SecretInfo, operationRequest: OperationRequest): Promise<OperationResponse>;
|
|
17
|
+
serverHandle(secretInfo: SecretInfo, operationRequest: OperationRequest): Promise<OperationResponse>;
|
|
18
|
+
adminHandle(secretInfo: SecretInfo, operationRequest: OperationRequest): Promise<OperationResponse>;
|
|
19
|
+
private execute;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { OperationRequest } from "./../../../../../GN-common/entity/operationRequest/OperationRequest";
|
|
2
|
+
import { OperationResponse } from "./../../../../../GN-common/entity/operationResponse/OperationResponse";
|
|
3
|
+
import { AuthInfo } from "./../../../../../GN-common/entity/AuthInfo";
|
|
4
|
+
import { SecretInfo } from "./../../../../../GN-common/entity/SecretInfo";
|
|
5
|
+
import { RequestHandler } from "./../base/RequestHandler";
|
|
6
|
+
declare class GetFunctionOperationRequest extends OperationRequest {
|
|
7
|
+
version: string;
|
|
8
|
+
isValidRequest(): boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare class GetFunctionRequestHandler extends RequestHandler {
|
|
11
|
+
getCode(): number;
|
|
12
|
+
getCommonOperationRequest(): typeof GetFunctionOperationRequest;
|
|
13
|
+
handle(authInfo: AuthInfo, secretInfo: SecretInfo, operationRequest: OperationRequest): Promise<OperationResponse>;
|
|
14
|
+
serverHandle(secretInfo: SecretInfo, operationRequest: OperationRequest): Promise<OperationResponse>;
|
|
15
|
+
adminHandle(secretInfo: SecretInfo, operationRequest: OperationRequest): Promise<OperationResponse>;
|
|
16
|
+
private execute;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
package/dist/GN-app-api/handler/controller/handler/cloudScript/GetFunctionsRequestHandler.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { OperationRequest } from "./../../../../../GN-common/entity/operationRequest/OperationRequest";
|
|
2
|
+
import { OperationResponse } from "./../../../../../GN-common/entity/operationResponse/OperationResponse";
|
|
3
|
+
import { AuthInfo } from "./../../../../../GN-common/entity/AuthInfo";
|
|
4
|
+
import { SecretInfo } from "./../../../../../GN-common/entity/SecretInfo";
|
|
5
|
+
import { RequestHandler } from "./../base/RequestHandler";
|
|
6
|
+
declare class GetFunctionsOperationRequest extends OperationRequest {
|
|
7
|
+
isValidRequest(): boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare class GetFunctionsRequestHandler extends RequestHandler {
|
|
10
|
+
getCode(): number;
|
|
11
|
+
getCommonOperationRequest(): typeof GetFunctionsOperationRequest;
|
|
12
|
+
handle(authInfo: AuthInfo, secretInfo: SecretInfo, operationRequest: OperationRequest): Promise<OperationResponse>;
|
|
13
|
+
serverHandle(secretInfo: SecretInfo, operationRequest: OperationRequest): Promise<OperationResponse>;
|
|
14
|
+
adminHandle(secretInfo: SecretInfo, operationRequest: OperationRequest): Promise<OperationResponse>;
|
|
15
|
+
private execute;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -3,7 +3,7 @@ import { OperationResponse } from "./../../../../../GN-common/entity/operationRe
|
|
|
3
3
|
import { AuthInfo } from "./../../../../../GN-common/entity/AuthInfo";
|
|
4
4
|
import { SecretInfo, SecretPermissionItem } from "./../../../../../GN-common/entity/SecretInfo";
|
|
5
5
|
import { RequestHandler } from "./../base/RequestHandler";
|
|
6
|
-
import { GNHashtable } from "
|
|
6
|
+
import { GNHashtable } from "./../../../../../GN-common/common/GNData";
|
|
7
7
|
declare class GetSecretInfoInformationOperationRequest extends OperationRequest {
|
|
8
8
|
secretKey: string;
|
|
9
9
|
isValidRequest(): boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PermissionRulesParam } from "./PermissionRulesParam";
|
|
2
|
+
export declare class CloudScriptPermissionRulesParam {
|
|
3
|
+
addFunction?: PermissionRulesParam;
|
|
4
|
+
getFunctions?: PermissionRulesParam;
|
|
5
|
+
editFunction?: PermissionRulesParam;
|
|
6
|
+
executeFunction?: PermissionRulesParam;
|
|
7
|
+
getFunction?: PermissionRulesParam;
|
|
8
|
+
}
|
|
@@ -8,6 +8,7 @@ import { MasterAdminPermissionRulesParam } from "./MasterAdminPermissionRulesPar
|
|
|
8
8
|
import { MasterPlayerPermissionRulesParam } from "./MasterPlayerPermissionRulesParam";
|
|
9
9
|
import { MultiplayerPermissionRulesParam } from "./MultiplayerPermissionRulesParam";
|
|
10
10
|
import { StoreInventoryPermissionRulesParam } from "./StoreInventoryPermissionRulesParam";
|
|
11
|
+
import { CloudScriptPermissionRulesParam } from "./CloudScriptPermissionRulesParam";
|
|
11
12
|
export declare class PermissionParam {
|
|
12
13
|
authenticate?: AuthenticatePermissionRulesParam;
|
|
13
14
|
masterPlayer?: MasterPlayerPermissionRulesParam;
|
|
@@ -19,4 +20,5 @@ export declare class PermissionParam {
|
|
|
19
20
|
storeInventory?: StoreInventoryPermissionRulesParam;
|
|
20
21
|
masterAdmin?: MasterAdminPermissionRulesParam;
|
|
21
22
|
multiplayer?: MultiplayerPermissionRulesParam;
|
|
23
|
+
cloudScript?: CloudScriptPermissionRulesParam;
|
|
22
24
|
}
|
|
@@ -4,7 +4,7 @@ import { AuthInfo } from "./../../../../../GN-common/entity/AuthInfo";
|
|
|
4
4
|
import { SecretInfo } from "./../../../../../GN-common/entity/SecretInfo";
|
|
5
5
|
import { MasterPlayerBaseRequestHandler } from "./MasterPlayerBaseRequestHandler";
|
|
6
6
|
declare class ResetAccountPasswordOperationRequest extends OperationRequest {
|
|
7
|
-
userId
|
|
7
|
+
userId?: string;
|
|
8
8
|
password: string;
|
|
9
9
|
isValidRequest(): boolean;
|
|
10
10
|
}
|
package/dist/GN-app-api/handler/controller/handler/masterPlayer/SetAvatarRequestHandler.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { AuthInfo } from "./../../../../../GN-common/entity/AuthInfo";
|
|
|
4
4
|
import { SecretInfo } from "./../../../../../GN-common/entity/SecretInfo";
|
|
5
5
|
import { MasterPlayerBaseRequestHandler } from "./MasterPlayerBaseRequestHandler";
|
|
6
6
|
declare class SetAvatarOperationRequest extends OperationRequest {
|
|
7
|
-
userId
|
|
7
|
+
userId?: string;
|
|
8
8
|
type: number;
|
|
9
9
|
value: string;
|
|
10
10
|
isValidRequest(): boolean;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ExecuteResult, ICloudScriptService } from "./ICloudScriptService";
|
|
2
|
+
import * as mongoDB from "mongodb";
|
|
3
|
+
import { GNServerSettingsOptions } from "@xmobitea/gn-typescript-client";
|
|
4
|
+
export declare class CloudScriptService implements ICloudScriptService {
|
|
5
|
+
private static readonly ExecuteTimeoutInMs;
|
|
6
|
+
private cloudScriptWorkerDict;
|
|
7
|
+
private cloudScriptWaitingResponseCallbackDict;
|
|
8
|
+
private latestVersion;
|
|
9
|
+
private liveLatestVersion;
|
|
10
|
+
private cloudScriptFunctionCollection;
|
|
11
|
+
private cloudScriptFunctionLogCollection;
|
|
12
|
+
private gnServerSettingsOptions;
|
|
13
|
+
private cloudScriptFunctions;
|
|
14
|
+
constructor();
|
|
15
|
+
init(gnServerSettingsOptions: GNServerSettingsOptions): void;
|
|
16
|
+
setCloudScriptFunctionCollection(cloudScriptFunctionCollection: mongoDB.Collection<mongoDB.Document>): void;
|
|
17
|
+
setCloudScriptFunctionLogCollection(cloudScriptFunctionLogCollection: mongoDB.Collection<mongoDB.Document>): void;
|
|
18
|
+
run(): void;
|
|
19
|
+
private loadVersion;
|
|
20
|
+
executeCloudScriptFunction(userId: string, functionName: string, functionParameter: object, version: string, customTags: {
|
|
21
|
+
[k: string]: any;
|
|
22
|
+
}): Promise<ExecuteResult>;
|
|
23
|
+
addCloudScriptFunction(script: string, isLive: boolean, canExecute: boolean): Promise<{
|
|
24
|
+
success: boolean;
|
|
25
|
+
errorMessage?: string;
|
|
26
|
+
version?: string;
|
|
27
|
+
}>;
|
|
28
|
+
editCloudScriptFunction(version: string, isLive: boolean, canExecute: boolean): Promise<{
|
|
29
|
+
success: boolean;
|
|
30
|
+
errorMessage?: string;
|
|
31
|
+
}>;
|
|
32
|
+
getCloudScriptFunctions(): Array<{
|
|
33
|
+
version: string;
|
|
34
|
+
canExecute: boolean;
|
|
35
|
+
}>;
|
|
36
|
+
getCloudScriptFunction(version: string): Promise<{
|
|
37
|
+
script: string;
|
|
38
|
+
canExecute: boolean;
|
|
39
|
+
isLive: boolean;
|
|
40
|
+
tsCreate: number;
|
|
41
|
+
}>;
|
|
42
|
+
getLatestVersion(): string;
|
|
43
|
+
getLiveLatestVersion(): string;
|
|
44
|
+
private loadCloudScriptFunctionWorkerFromCache;
|
|
45
|
+
private loadCloudScriptFunctionWorker;
|
|
46
|
+
private loadCloudScriptWorker;
|
|
47
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export declare enum ExecuteResponseStatus {
|
|
2
|
+
Ok = 1,
|
|
3
|
+
Exception = 2,
|
|
4
|
+
FunctionNameNotFound = 3,
|
|
5
|
+
VersionInvalid = 4,
|
|
6
|
+
Timeout = 5
|
|
7
|
+
}
|
|
8
|
+
export interface ExecuteResult {
|
|
9
|
+
stats: {
|
|
10
|
+
memoryUsedInBytes: number;
|
|
11
|
+
executeTimeInMs: number;
|
|
12
|
+
};
|
|
13
|
+
response: {
|
|
14
|
+
status: ExecuteResponseStatus;
|
|
15
|
+
result: any;
|
|
16
|
+
errorMessage: any;
|
|
17
|
+
};
|
|
18
|
+
logs: string[];
|
|
19
|
+
}
|
|
20
|
+
export interface ICloudScriptService {
|
|
21
|
+
executeCloudScriptFunction(userId: string, functionName: string, functionParameter: object, version: string, customTags: {
|
|
22
|
+
[k: string]: any;
|
|
23
|
+
}): Promise<ExecuteResult>;
|
|
24
|
+
addCloudScriptFunction(script: string, isLive: boolean, canExecute: boolean): Promise<{
|
|
25
|
+
success: boolean;
|
|
26
|
+
errorMessage?: string;
|
|
27
|
+
version?: string;
|
|
28
|
+
}>;
|
|
29
|
+
editCloudScriptFunction(version: string, isLive: boolean, canExecute: boolean): Promise<{
|
|
30
|
+
success: boolean;
|
|
31
|
+
errorMessage?: string;
|
|
32
|
+
}>;
|
|
33
|
+
getCloudScriptFunction(version: string): Promise<{
|
|
34
|
+
script: string;
|
|
35
|
+
canExecute: boolean;
|
|
36
|
+
isLive: boolean;
|
|
37
|
+
tsCreate: number;
|
|
38
|
+
}>;
|
|
39
|
+
getCloudScriptFunctions(): Array<{
|
|
40
|
+
version: string;
|
|
41
|
+
canExecute: boolean;
|
|
42
|
+
}>;
|
|
43
|
+
}
|
|
@@ -181,4 +181,9 @@ export declare class OperationCode {
|
|
|
181
181
|
static readonly JoinMatchmakingTicket: number;
|
|
182
182
|
static readonly ListMatchmakingTicketsForPlayer: number;
|
|
183
183
|
static readonly GetCurrencyLeaderboard: number;
|
|
184
|
+
static readonly ExecuteFunction: number;
|
|
185
|
+
static readonly GetFunctions: number;
|
|
186
|
+
static readonly AddFunction: number;
|
|
187
|
+
static readonly EditFunction: number;
|
|
188
|
+
static readonly GetFunction: number;
|
|
184
189
|
}
|
|
@@ -427,4 +427,20 @@ export declare class GNParameterCode {
|
|
|
427
427
|
static readonly GetQueueStatistics: string;
|
|
428
428
|
static readonly JoinMatchmakingTicket: string;
|
|
429
429
|
static readonly ListMatchmakingTicketsForPlayer: string;
|
|
430
|
+
static readonly FunctionName: string;
|
|
431
|
+
static readonly FunctionParameter: string;
|
|
432
|
+
static readonly Version: string;
|
|
433
|
+
static readonly FunctionResult: string;
|
|
434
|
+
static readonly ExecutionTimeInMs: string;
|
|
435
|
+
static readonly MemoryUsedInBytes: string;
|
|
436
|
+
static readonly FunctionLogs: string;
|
|
437
|
+
static readonly CanExecute: string;
|
|
438
|
+
static readonly Script: string;
|
|
439
|
+
static readonly IsLive: string;
|
|
440
|
+
static readonly AddFunction: string;
|
|
441
|
+
static readonly GetFunctions: string;
|
|
442
|
+
static readonly EditFunction: string;
|
|
443
|
+
static readonly ExecuteFunction: string;
|
|
444
|
+
static readonly GetFunction: string;
|
|
445
|
+
static readonly CloudScript: string;
|
|
430
446
|
}
|
|
@@ -4,7 +4,7 @@ import { GNArray, GNHashtable } from "./../common/GNData";
|
|
|
4
4
|
import { AbstractConstructor, GNObjectFieldMetadata, GNObjectMetadata } from "./GNMetadata";
|
|
5
5
|
export declare const initGNObjectMetadata: <T extends GNObjectMetadata>(prototype: any) => T;
|
|
6
6
|
export declare const initGNObjectFieldMetadata: <T extends GNObjectFieldMetadata>(prototype: any, propertyKey: string) => T;
|
|
7
|
-
export declare const getGNObjectMetadata: <T extends GNObjectMetadata>(obj: AbstractConstructor<any>) => T;
|
|
7
|
+
export declare const getGNObjectMetadata: <T extends GNObjectMetadata>(obj: AbstractConstructor<any>) => T | undefined;
|
|
8
8
|
export declare const setGNObjectMetadata: <T extends GNObjectMetadata>(obj: AbstractConstructor<any>, metadata: T) => void;
|
|
9
9
|
export declare const getTableName: (model: Constructor<any>) => string;
|
|
10
10
|
export interface GNEnhancedObjectFieldMetadata extends GNObjectFieldMetadata {
|
|
@@ -64,6 +64,12 @@ export interface MultiplayerPermissionRules {
|
|
|
64
64
|
adminSelfEnable: boolean;
|
|
65
65
|
serverSelfEnable: boolean;
|
|
66
66
|
}
|
|
67
|
+
export interface CloudScriptPermissionRules {
|
|
68
|
+
selfEnable: boolean;
|
|
69
|
+
otherSelfEnable: boolean;
|
|
70
|
+
adminSelfEnable: boolean;
|
|
71
|
+
serverSelfEnable: boolean;
|
|
72
|
+
}
|
|
67
73
|
export interface StoreInventoryPermissionRules {
|
|
68
74
|
selfEnable: boolean;
|
|
69
75
|
otherSelfEnable: boolean;
|
|
@@ -384,6 +390,13 @@ export interface SecretPermissionItem {
|
|
|
384
390
|
joinMatchmakingTicket: MultiplayerPermissionRules;
|
|
385
391
|
listMatchmakingTicketsForPlayer: MultiplayerPermissionRules;
|
|
386
392
|
};
|
|
393
|
+
cloudScript: {
|
|
394
|
+
executeFunction: CloudScriptPermissionRules;
|
|
395
|
+
getFunctions: CloudScriptPermissionRules;
|
|
396
|
+
addFunction: CloudScriptPermissionRules;
|
|
397
|
+
editFunction: CloudScriptPermissionRules;
|
|
398
|
+
getFunction: CloudScriptPermissionRules;
|
|
399
|
+
};
|
|
387
400
|
}
|
|
388
401
|
declare abstract class BuilderBase {
|
|
389
402
|
protected secretKey: string;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { GNNetwork, GNServerSettings, GNServerSettingsOptions } from '@xmobitea/gn-typescript-client';
|
|
2
|
+
import { parentPort, workerData } from 'worker_threads';
|
|
3
|
+
|
|
4
|
+
interface CloudScriptRequest {
|
|
5
|
+
requestId: string,
|
|
6
|
+
userId: string,
|
|
7
|
+
name: string,
|
|
8
|
+
parameter: object,
|
|
9
|
+
customTags: {[k: string]: any},
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface CloudScriptResponse {
|
|
13
|
+
stats: {
|
|
14
|
+
memoryUsedInBytes: number,
|
|
15
|
+
executeTimeInMs: number,
|
|
16
|
+
},
|
|
17
|
+
response: FunctionResponse,
|
|
18
|
+
responseId: string,
|
|
19
|
+
logs: string[],
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface FunctionRequest {
|
|
24
|
+
userId: string;
|
|
25
|
+
name: string;
|
|
26
|
+
parameter: object;
|
|
27
|
+
context: {
|
|
28
|
+
|
|
29
|
+
};
|
|
30
|
+
log: (log: any) => void,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface FunctionResponse {
|
|
34
|
+
status: "ok" | "exception" | "commandNotFound",
|
|
35
|
+
result: any,
|
|
36
|
+
errorMessage: any,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
let gnServerSettingsOptions: GNServerSettingsOptions = workerData.gnServerSettingsOptions;
|
|
40
|
+
|
|
41
|
+
let gnServerSettings = new GNServerSettings();
|
|
42
|
+
gnServerSettings.config(gnServerSettingsOptions);
|
|
43
|
+
|
|
44
|
+
GNNetwork.init(gnServerSettings);
|
|
45
|
+
|
|
46
|
+
if (parentPort) {
|
|
47
|
+
parentPort.on("message", async (request: CloudScriptRequest) => {
|
|
48
|
+
let startTime = performance.now();
|
|
49
|
+
let startMemoryUsage = process.memoryUsage();
|
|
50
|
+
|
|
51
|
+
let logs: string[] = [];
|
|
52
|
+
let functionRequest: FunctionRequest = {
|
|
53
|
+
userId: request.userId,
|
|
54
|
+
name: request.name,
|
|
55
|
+
parameter: request.parameter,
|
|
56
|
+
context: {
|
|
57
|
+
|
|
58
|
+
},
|
|
59
|
+
log(log: any) {
|
|
60
|
+
logs.push(log);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
let handleResponse = await ___handleFunction(functionRequest);
|
|
65
|
+
|
|
66
|
+
let endTime = performance.now();
|
|
67
|
+
let endMemoryUsage = process.memoryUsage();
|
|
68
|
+
|
|
69
|
+
let memoryUsedInBytes = endMemoryUsage.rss - startMemoryUsage.rss;
|
|
70
|
+
let executeTimeInMs = (endTime - startTime) * 1000;
|
|
71
|
+
|
|
72
|
+
//let cost = (memoryUsedInGb * executeTime) / 1000 * 0.022;
|
|
73
|
+
|
|
74
|
+
let response: CloudScriptResponse = {
|
|
75
|
+
responseId: request.requestId,
|
|
76
|
+
response: handleResponse,
|
|
77
|
+
stats: {
|
|
78
|
+
executeTimeInMs: executeTimeInMs,
|
|
79
|
+
memoryUsedInBytes: memoryUsedInBytes,
|
|
80
|
+
},
|
|
81
|
+
logs: logs,
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
parentPort?.postMessage(response);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async function ___handleFunction(request: FunctionRequest): Promise<FunctionResponse> {
|
|
89
|
+
let handler = handlers[request.name];
|
|
90
|
+
|
|
91
|
+
if (handler == null) {
|
|
92
|
+
return {
|
|
93
|
+
status: 'commandNotFound',
|
|
94
|
+
result: null,
|
|
95
|
+
errorMessage: null,
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
let answer: FunctionResponse = {
|
|
100
|
+
status: 'ok',
|
|
101
|
+
errorMessage: null,
|
|
102
|
+
result: null,
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
answer.result = await handler(request);
|
|
107
|
+
}
|
|
108
|
+
catch (err: any) {
|
|
109
|
+
answer.status = 'exception';
|
|
110
|
+
answer.errorMessage = err.message;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return answer;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const handlers: Record<string, (request: FunctionRequest) => any> = {};
|
|
117
|
+
|
|
118
|
+
//$replaceScript
|
|
@@ -5,6 +5,7 @@ import { ApplicationSettings } from "./../settings/ApplicationSettings";
|
|
|
5
5
|
import { SocketAppSettings } from "./../settings/SocketAppSettings";
|
|
6
6
|
import { HttpAppSettings } from "./../settings/HttpAppSettings";
|
|
7
7
|
import { LogSettings } from "./../settings/LogSettings";
|
|
8
|
+
import { GNServerSettingsOptions } from "@xmobitea/gn-typescript-client";
|
|
8
9
|
export declare class AdminAppHandler {
|
|
9
10
|
private applicationSettings;
|
|
10
11
|
private apiMiddleware;
|
|
@@ -25,6 +26,6 @@ export declare class AdminAppHandler {
|
|
|
25
26
|
private mustSignin;
|
|
26
27
|
private mustNotSignin;
|
|
27
28
|
run(): void;
|
|
28
|
-
runGNNetworkSdk(
|
|
29
|
+
runGNNetworkSdk(gnServerSettingsOptions: GNServerSettingsOptions): void;
|
|
29
30
|
private setupAdminRouter;
|
|
30
31
|
}
|
|
@@ -51,7 +51,7 @@ export declare class SocketAppHandler {
|
|
|
51
51
|
sendEventToAllPlayer(operationEvent: OperationEvent): Promise<void>;
|
|
52
52
|
sendEventToNamespace(namespace: string, operationEvent: OperationEvent): Promise<void>;
|
|
53
53
|
getSocketViaSocketId(socketId: string): Socket;
|
|
54
|
-
getSockets(userId: string): import("socket.io").BroadcastOperator<import("socket.io/dist/typed-events").DecorateAcknowledgementsWithMultipleResponses<import("socket.io
|
|
54
|
+
getSockets(userId: string): import("socket.io").BroadcastOperator<import("socket.io/dist/typed-events").DecorateAcknowledgementsWithMultipleResponses<import("socket.io").DefaultEventsMap>, any>;
|
|
55
55
|
joinRoom(userId: string, roomId: string): Promise<void>;
|
|
56
56
|
leaveRoom(userId: string, roomId: string): Promise<void>;
|
|
57
57
|
getRooms(userId: string): Promise<string[]>;
|
package/dist/GNServer.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { xMail } from "./GN-library/xmail/lib/xMail";
|
|
|
9
9
|
import { IFacebookService } from "./GN-app-api/service/IFacebookService";
|
|
10
10
|
import { IGenericService } from "./GN-app-api/service/IGenericService";
|
|
11
11
|
import { IAppleService } from "./GN-app-api/service/IAppleService";
|
|
12
|
+
import { ICloudScriptService } from "./GN-app-api/service/ICloudScriptService";
|
|
12
13
|
import { ITimerService } from "./GN-app-api/service/ITimerService";
|
|
13
14
|
import { OnRunSuccess } from "./GN-library/xbuilder/lib/OnRunSuccess";
|
|
14
15
|
import { ILockService } from "./GN-app-api/service/ILockService";
|
|
@@ -45,6 +46,7 @@ export declare class GNServer {
|
|
|
45
46
|
private analyticsService;
|
|
46
47
|
private postEventCallbackService;
|
|
47
48
|
private preEventCallbackService;
|
|
49
|
+
private cloudScriptService;
|
|
48
50
|
private gameIds;
|
|
49
51
|
private matchmakingHandler;
|
|
50
52
|
constructor();
|
|
@@ -78,6 +80,7 @@ export declare class GNServer {
|
|
|
78
80
|
getLockService(): ILockService;
|
|
79
81
|
getAnalyticsService(): IAnalyticsService;
|
|
80
82
|
getRequestConverterService(): IRequestConverterService;
|
|
83
|
+
getCloudScriptService(): ICloudScriptService;
|
|
81
84
|
sendEventTo(userId: string, operationEvent: OperationEvent): Promise<void>;
|
|
82
85
|
sendEventToRoom(roomId: string, operationEvent: OperationEvent): Promise<void>;
|
|
83
86
|
sendEventToMoreUser(userIds: string[], operationEvent: OperationEvent): Promise<void>;
|