@xmobitea/gn-server
Version:
GearN Server by XmobiTea (Pro)
177 lines (176 loc) • 7.45 kB
TypeScript
import { SecretInfo } from "./../../GN-common/entity/SecretInfo";
import { OperationRequest } from "./../../GN-common/entity/operationRequest/OperationRequest";
import { OperationResponse } from "./../../GN-common/entity/operationResponse/OperationResponse";
import { IPostEventCallbackService, IPreEventCallbackService, OnPostCallbackFunction, OnPreCallbackFunction } from "./IEventCallbackService";
import * as mongoDB from "mongodb";
import { GNServer } from "./../../GNServer";
import { GNServerSettingsOptions } from "@xmobitea/gn-typescript-client";
import { OperationEvent } from "./../../GN-common/entity/operationEvent/OperationEvent";
import { MatchmakingTicketCanMatch } from "./../handler/controller/handler/multiplayer/MatchmakingHandler";
interface DbConnection {
url: string;
dbName: string;
logUrl: string;
logDbName: string;
options?: {
[k: string]: any;
};
}
export interface EventCallbackCloudScriptFunction {
type: string;
version: string;
fullScript: string;
tsLastUpdate: number;
childScripts: {
eventName: string;
script: string;
hasEdit: boolean;
}[];
}
export interface IEventCallbackCloudScriptService {
executeRequestServerDetailSystem(gameId: string, matchmakingTicketCanMatch: MatchmakingTicketCanMatch): Promise<{
success: boolean;
}>;
executePost(eventName: string, request: {
[k: string]: any;
}, secretInfo: SecretInfo, operationRequest: OperationRequest, operationResponse: OperationResponse): Promise<void>;
executeEvent(eventName: string, request: {
[k: string]: any;
}, operationEvent: OperationEvent): Promise<void>;
executePre(eventName: string, request: {
[k: string]: any;
}, secretInfo: SecretInfo, operationRequest: OperationRequest): Promise<OperationResponse>;
executeAuthenticate(eventName: string, request: {
userId: string;
ipAddress: string;
isNewUser: boolean;
authenticationType: string;
}, secretInfo: SecretInfo, operationRequest: OperationRequest, operationResponse: OperationResponse): Promise<void>;
executeVerifyGenericService(serviceName: string, serviceData: {
[k: string]: any;
}): Promise<{
success: boolean;
serviceId: string;
someDatas?: any;
errorMessage?: string;
}>;
addCloudScriptFunction(eventName: string, script: string): Promise<{
success: boolean;
errorMessage?: string;
version?: string;
}>;
getAllCloudScriptFunction(): Promise<{
type: string;
version: string;
fullScript: string;
tsLastUpdate: number;
childScripts: {
eventName: string;
script: string;
hasEdit: boolean;
}[];
}[]>;
}
export declare class EventCallbackCloudScriptService implements IEventCallbackCloudScriptService {
private static readonly SystemExecuteTimeoutInMs;
private static readonly OnEveryMinute;
private static readonly OnEveryHour;
private static readonly OnEveryDay;
private cloudScriptWorkerDict;
private cloudScriptWaitingResponseCallbackDict;
private cloudScriptFunctionCollection;
private backupCloudScriptFunctionCollection;
private gnServer;
private gnServerSettingsOptions;
private dbConnection;
private executeTimeoutInMs;
private cloudScriptFunctionDict;
constructor();
getAllCloudScriptFunction(): Promise<{
type: string;
version: string;
fullScript: string;
tsLastUpdate: number;
childScripts: {
eventName: string;
script: string;
hasEdit: boolean;
}[];
}[]>;
init(gnServerSettingsOptions: GNServerSettingsOptions, dbConnection: DbConnection, gnServer: GNServer, executeTimeoutInMs: number): void;
setCloudScriptFunctionCollection(cloudScriptFunctionCollection: mongoDB.Collection<mongoDB.Document>): void;
setBackupCloudScriptFunctionCollection(cloudScriptFunctionCollection: mongoDB.Collection<mongoDB.Document>): void;
run(): void;
private loadVersion;
private executeSystem;
executeRequestServerDetailSystem(gameId: string, matchmakingTicketCanMatch: MatchmakingTicketCanMatch): Promise<{
success: boolean;
}>;
executeEvent(eventName: string, request: {
[k: string]: any;
}, operationEvent: OperationEvent): Promise<void>;
executePre(eventName: string, request: {
[k: string]: any;
}, secretInfo: SecretInfo, operationRequest: OperationRequest): Promise<OperationResponse>;
executeVerifyGenericService(serviceName: string, serviceData: {
[k: string]: any;
}): Promise<{
success: boolean;
serviceId: string;
someDatas?: any;
errorMessage?: string;
}>;
executeAuthenticate(eventName: string, request: {
userId: string;
ipAddress: string;
isNewUser: boolean;
authenticationType: string;
}, secretInfo: SecretInfo, operationRequest: OperationRequest, operationResponse: OperationResponse): Promise<void>;
executePost(eventName: string, request: {
[k: string]: any;
}, secretInfo: SecretInfo, operationRequest: OperationRequest, operationResponse: OperationResponse): Promise<void>;
private loadCloudScriptFunctionWorkerFromCache;
addCloudScriptFunction(eventName: string, script: string): Promise<{
success: boolean;
errorMessage?: string;
version?: string;
}>;
private remoteAddCloudScriptFunction;
private loadCloudScriptFunctionWorker;
private loadCloudScriptWorker;
}
export declare class PostEventCallbackService implements IPostEventCallbackService {
private eventLstDict;
constructor();
private eventCallbackLogCollection;
private cloudScriptService;
subscriberEvent(eventName: string, callbackFunction: OnPostCallbackFunction): void;
unSubscriberEvent(eventName: string, callbackFunction: OnPostCallbackFunction): void;
setEventCallbackLogCollection(eventCallbackLogCollection: mongoDB.Collection<mongoDB.Document>): void;
setCloudScriptService(cloudScriptService: IEventCallbackCloudScriptService): void;
onEvent(eventName: string, request: {}, secretInfo: SecretInfo, operationRequest: OperationRequest, operationResponse: OperationResponse): Promise<void>;
onAuthenticateEvent(eventName: string, request: {
userId: string;
ipAddress: string;
isNewUser: boolean;
authenticationType: string;
}, secretInfo: SecretInfo, operationRequest: OperationRequest, operationResponse: OperationResponse): Promise<void>;
onVerifyGenericService(serviceName: string, serviceData: {
[k: string]: any;
}): Promise<{
success: boolean;
serviceId: string;
someDatas?: any;
errorMessage?: string;
}>;
}
export declare class PreEventCallbackService implements IPreEventCallbackService {
private eventDict;
private cloudScriptService;
constructor();
subscriberEvent(eventName: string, callbackFunction: OnPreCallbackFunction): void;
unSubscriberEvent(eventName: string): void;
setCloudScriptService(cloudScriptService: IEventCallbackCloudScriptService): void;
onEvent(eventName: string, request: {}, secretInfo: SecretInfo, operationRequest: OperationRequest): Promise<OperationResponse>;
}
export {};