@xmobitea/gn-server 2.6.6 → 2.6.8
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/LICENSE +198 -5
- package/dist/GN-app-api/handler/controller/handler/characterPlayer/model/GroupMemberParam.d.ts +0 -1
- package/dist/GN-app-api/handler/controller/handler/cloudScript/ExecuteFunctionRequestHandler.d.ts +1 -1
- package/dist/GN-app-api/handler/controller/handler/group/model/GroupMemberParam.d.ts +0 -1
- package/dist/GN-app-api/handler/controller/handler/masterPlayer/SetPlayerBanRequestHandler.d.ts +2 -0
- package/dist/GN-app-api/service/CloudScriptEventService.d.ts +144 -0
- package/dist/GN-app-api/service/CloudScriptService.d.ts +1 -1
- package/dist/GN-app-api/service/EventCallbackService.d.ts +9 -17
- package/dist/GN-app-api/service/ICloudScriptService.d.ts +2 -2
- package/dist/GN-app-api/service/IEventCallbackService.d.ts +0 -14
- package/dist/GN-app-api/{handler/controller/handler/multiplayer/MatchmakingHandler.d.ts → service/IMatchmakingService.d.ts} +2 -19
- package/dist/GN-app-api/service/MatchmakingService.d.ts +21 -0
- package/dist/GN-startup/cloudScript/CloudScriptAdmin.ts +74 -0
- package/dist/GN-startup/cloudScript/CloudScriptDatabase.ts +93 -0
- package/dist/GN-startup/cloudScript/CloudScriptEvent.ts +158 -0
- package/dist/GN-startup/cloudScript/CloudScriptHttp.ts +31 -0
- package/dist/GN-startup/cloudScript/CloudScriptMail.ts +26 -0
- package/dist/GN-startup/cloudScript/CloudScriptMatchmaking.ts +14 -0
- package/dist/GN-startup/cloudScript/CloudScriptPushNotification.ts +65 -0
- package/dist/GN-startup/cloudScript/CloudScriptSocket.ts +64 -0
- package/dist/GN-startup/cloudScript/eventCallbackCloudScriptData.json +59 -17
- package/dist/GN-startup/cloudScript/templateCloudScript.ts +26 -385
- package/dist/GN-startup/cloudScript/templateEventCallback.ts +301 -509
- package/dist/GN-startup/middleware/ApiMiddleware.d.ts +1 -0
- package/dist/GN-startup/routes/SocketAppHandler.d.ts +7 -0
- package/dist/GNServer.d.ts +5 -1
- package/dist/RequestControllerUtils.d.ts +4 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2487 -2413
- package/package.json +3 -3
- package/apiReferences/Authenticate.json +0 -1
- package/apiReferences/CharacterPlayer.json +0 -1
- package/apiReferences/CloudScript.json +0 -1
- package/apiReferences/Content.json +0 -1
- package/apiReferences/GamePlayer.json +0 -1
- package/apiReferences/Group.json +0 -1
- package/apiReferences/Inventory.json +0 -1
- package/apiReferences/MasterAdmin.json +0 -1
- package/apiReferences/MasterPlayer.json +0 -1
- package/apiReferences/Multiplayer.json +0 -1
- package/apiReferences/StoreInventory.json +0 -1
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import * as mongodb from "mongodb";
|
|
2
|
+
|
|
3
|
+
export class CloudScriptDatabase {
|
|
4
|
+
private static readonly DOT: string = ".";
|
|
5
|
+
private static readonly RUNTIME: string = "Runtime" + CloudScriptDatabase.DOT;
|
|
6
|
+
private static readonly META: string = "Meta" + CloudScriptDatabase.DOT;
|
|
7
|
+
private static readonly SYSTEM: string = "System" + CloudScriptDatabase.DOT;
|
|
8
|
+
|
|
9
|
+
private client: mongodb.MongoClient;
|
|
10
|
+
private db: mongodb.Db;
|
|
11
|
+
|
|
12
|
+
private logClient: mongodb.MongoClient;
|
|
13
|
+
private logDb: mongodb.Db;
|
|
14
|
+
|
|
15
|
+
init(url: string, dbName: string, logUrl: string, logDbName: string, options?: mongodb.MongoClientOptions): void {
|
|
16
|
+
this.client = new mongodb.MongoClient(url, options);
|
|
17
|
+
|
|
18
|
+
this.db = this.client.db(dbName);
|
|
19
|
+
|
|
20
|
+
if (!logUrl || logUrl == "" || logUrl == url) {
|
|
21
|
+
this.logClient = this.client;
|
|
22
|
+
this.logDb = this.db;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
this.logClient = new mongodb.MongoClient(logUrl, options);
|
|
26
|
+
this.logDb = this.logClient.db(logDbName);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public runtimeCollection<TSchema extends mongodb.Document = mongodb.Document>(collectionName: string): mongodb.Collection<TSchema> {
|
|
31
|
+
return this.collection<TSchema>(CloudScriptDatabase.RUNTIME + collectionName);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public metaCollection<TSchema extends mongodb.Document = mongodb.Document>(collectionName: string): mongodb.Collection<TSchema> {
|
|
35
|
+
return this.collection<TSchema>(CloudScriptDatabase.META + collectionName);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public systemCollection<TSchema extends mongodb.Document = mongodb.Document>(collectionName: string): mongodb.Collection<TSchema> {
|
|
39
|
+
return this.collection<TSchema>(CloudScriptDatabase.SYSTEM + collectionName);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public runtimeGameCollection<TSchema extends mongodb.Document = mongodb.Document>(collectionName: string, gameId: string): mongodb.Collection<TSchema> {
|
|
43
|
+
return this.collection<TSchema>(CloudScriptDatabase.RUNTIME + gameId + CloudScriptDatabase.DOT + collectionName);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public metaGameCollection<TSchema extends mongodb.Document = mongodb.Document>(collectionName: string, gameId: string): mongodb.Collection<TSchema> {
|
|
47
|
+
return this.collection<TSchema>(CloudScriptDatabase.META + gameId + CloudScriptDatabase.DOT + collectionName);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public systemGameCollection<TSchema extends mongodb.Document = mongodb.Document>(collectionName: string, gameId: string): mongodb.Collection<TSchema> {
|
|
51
|
+
return this.collection<TSchema>(CloudScriptDatabase.SYSTEM + gameId + CloudScriptDatabase.DOT + collectionName);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public collection<TSchema extends mongodb.Document = mongodb.Document>(fullCollectionName: string): mongodb.Collection<TSchema> {
|
|
55
|
+
return this.db.collection<TSchema>(fullCollectionName);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public createCollection(name: string, options?: mongodb.CreateCollectionOptions): Promise<mongodb.Collection<mongodb.BSON.Document>> {
|
|
59
|
+
return this.db.createCollection(name, options);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public logRuntimeCollection<TSchema extends mongodb.Document = mongodb.Document>(collectionName: string): mongodb.Collection<TSchema> {
|
|
63
|
+
return this.logCollection<TSchema>(CloudScriptDatabase.RUNTIME + collectionName);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public logMetaCollection<TSchema extends mongodb.Document = mongodb.Document>(collectionName: string): mongodb.Collection<TSchema> {
|
|
67
|
+
return this.logCollection<TSchema>(CloudScriptDatabase.META + collectionName);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public logSystemCollection<TSchema extends mongodb.Document = mongodb.Document>(collectionName: string): mongodb.Collection<TSchema> {
|
|
71
|
+
return this.logCollection<TSchema>(CloudScriptDatabase.SYSTEM + collectionName);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public logRuntimeGameCollection<TSchema extends mongodb.Document = mongodb.Document>(collectionName: string, gameId: string): mongodb.Collection<TSchema> {
|
|
75
|
+
return this.logCollection<TSchema>(CloudScriptDatabase.RUNTIME + gameId + CloudScriptDatabase.DOT + collectionName);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
public logMetaGameCollection<TSchema extends mongodb.Document = mongodb.Document>(collectionName: string, gameId: string): mongodb.Collection<TSchema> {
|
|
79
|
+
return this.logCollection<TSchema>(CloudScriptDatabase.META + gameId + CloudScriptDatabase.DOT + collectionName);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public logSystemGameCollection<TSchema extends mongodb.Document = mongodb.Document>(collectionName: string, gameId: string): mongodb.Collection<TSchema> {
|
|
83
|
+
return this.logCollection<TSchema>(CloudScriptDatabase.SYSTEM + gameId + CloudScriptDatabase.DOT + collectionName);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
public logCollection<TSchema extends mongodb.Document = mongodb.Document>(fullCollectionName: string): mongodb.Collection<TSchema> {
|
|
87
|
+
return this.logDb.collection<TSchema>(fullCollectionName);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public logCreateCollection<TSchema extends mongodb.Document = mongodb.Document>(collectionName: string, options?: mongodb.CreateCollectionOptions) {
|
|
91
|
+
return this.logDb.createCollection<TSchema>(collectionName, options)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { MatchmakingTicketCanMatch, ServerDetail } from "./../../index";
|
|
2
|
+
|
|
3
|
+
export enum CloudScriptEventType {
|
|
4
|
+
SendEventToOne = 0,
|
|
5
|
+
SendEventToMore = 1,
|
|
6
|
+
SendEventToAll = 2,
|
|
7
|
+
JoinRoom = 3,
|
|
8
|
+
LeaveRoom = 4,
|
|
9
|
+
SendEventToRoom = 5,
|
|
10
|
+
|
|
11
|
+
ConfirmServerDetail = 10,
|
|
12
|
+
|
|
13
|
+
SendMailToOne = 20,
|
|
14
|
+
SendMailToMore = 21,
|
|
15
|
+
|
|
16
|
+
SendPushNotificationToOne = 30,
|
|
17
|
+
SendPushNotificationToMore = 31,
|
|
18
|
+
SendPushNotificationToTopic = 32,
|
|
19
|
+
SubscribeToTopic = 33,
|
|
20
|
+
UnsubscribeFromTopic = 34,
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface CloudScriptEventSendEventToOne {
|
|
25
|
+
eventType: CloudScriptEventType.SendEventToOne;
|
|
26
|
+
operationEvent: {
|
|
27
|
+
eventCode: string;
|
|
28
|
+
parameters: {};
|
|
29
|
+
};
|
|
30
|
+
userId: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface CloudScriptEventSendEventToMore {
|
|
34
|
+
eventType: CloudScriptEventType.SendEventToMore;
|
|
35
|
+
operationEvent: {
|
|
36
|
+
eventCode: string;
|
|
37
|
+
parameters: {};
|
|
38
|
+
};
|
|
39
|
+
userIds: string[];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface CloudScriptEventSendEventToAll {
|
|
43
|
+
eventType: CloudScriptEventType.SendEventToAll;
|
|
44
|
+
operationEvent: {
|
|
45
|
+
eventCode: string;
|
|
46
|
+
parameters: {};
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface CloudScriptEventJoinRoom {
|
|
51
|
+
eventType: CloudScriptEventType.JoinRoom;
|
|
52
|
+
userId: string;
|
|
53
|
+
roomId: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface CloudScriptEventLeaveRoom {
|
|
57
|
+
eventType: CloudScriptEventType.LeaveRoom;
|
|
58
|
+
userId: string;
|
|
59
|
+
roomId: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
interface CloudScriptEventSendEventToRoom {
|
|
63
|
+
eventType: CloudScriptEventType.SendEventToRoom;
|
|
64
|
+
roomId: string;
|
|
65
|
+
operationEvent: {
|
|
66
|
+
eventCode: string;
|
|
67
|
+
parameters: {};
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
interface CloudScriptEventConfirmServerDetail {
|
|
72
|
+
eventType: CloudScriptEventType.ConfirmServerDetail;
|
|
73
|
+
gameId: string;
|
|
74
|
+
matchmakingTicketCanMatch: MatchmakingTicketCanMatch;
|
|
75
|
+
serverDetail: ServerDetail;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
interface CloudScriptEventSendMailToOne {
|
|
79
|
+
eventType: CloudScriptEventType.SendMailToOne;
|
|
80
|
+
mailData: {
|
|
81
|
+
subject: string;
|
|
82
|
+
contentHtml: string;
|
|
83
|
+
};
|
|
84
|
+
email: string;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
interface CloudScriptEventSendMailToMore {
|
|
88
|
+
eventType: CloudScriptEventType.SendMailToMore;
|
|
89
|
+
mailData: {
|
|
90
|
+
subject: string;
|
|
91
|
+
contentHtml: string;
|
|
92
|
+
};
|
|
93
|
+
emails: string[];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
interface CloudScriptEventSendPushNotificationToOne {
|
|
97
|
+
eventType: CloudScriptEventType.SendPushNotificationToOne;
|
|
98
|
+
pushData: {
|
|
99
|
+
title: string;
|
|
100
|
+
body: string;
|
|
101
|
+
badge?: number;
|
|
102
|
+
sound?: string;
|
|
103
|
+
icon?: string;
|
|
104
|
+
data?: { [k: string]: any };
|
|
105
|
+
};
|
|
106
|
+
token: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
interface CloudScriptEventSendPushNotificationToMore {
|
|
110
|
+
eventType: CloudScriptEventType.SendPushNotificationToMore;
|
|
111
|
+
pushData: {
|
|
112
|
+
title: string;
|
|
113
|
+
body: string;
|
|
114
|
+
badge?: number;
|
|
115
|
+
sound?: string;
|
|
116
|
+
icon?: string;
|
|
117
|
+
data?: { [k: string]: any };
|
|
118
|
+
};
|
|
119
|
+
tokens: string[];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
interface CloudScriptEventSendPushNotificationToTopic {
|
|
123
|
+
eventType: CloudScriptEventType.SendPushNotificationToTopic;
|
|
124
|
+
pushData: {
|
|
125
|
+
title: string;
|
|
126
|
+
body: string;
|
|
127
|
+
badge?: number;
|
|
128
|
+
sound?: string;
|
|
129
|
+
icon?: string;
|
|
130
|
+
data?: { [k: string]: any };
|
|
131
|
+
};
|
|
132
|
+
topic: string;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
interface CloudScriptEventSubscribeToTopic {
|
|
136
|
+
eventType: CloudScriptEventType.SubscribeToTopic;
|
|
137
|
+
tokens: string[];
|
|
138
|
+
topic: string;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
interface CloudScriptEventUnsubscribeFromTopic {
|
|
142
|
+
eventType: CloudScriptEventType.UnsubscribeFromTopic;
|
|
143
|
+
tokens: string[];
|
|
144
|
+
topic: string;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
type CloudScriptEvent = CloudScriptEventSendEventToOne | CloudScriptEventSendEventToMore | CloudScriptEventSendEventToAll | CloudScriptEventJoinRoom | CloudScriptEventLeaveRoom | CloudScriptEventSendEventToRoom
|
|
148
|
+
| CloudScriptEventConfirmServerDetail
|
|
149
|
+
| CloudScriptEventSendMailToOne | CloudScriptEventSendMailToMore
|
|
150
|
+
| CloudScriptEventSendPushNotificationToOne | CloudScriptEventSendPushNotificationToMore | CloudScriptEventSendPushNotificationToTopic | CloudScriptEventSubscribeToTopic | CloudScriptEventUnsubscribeFromTopic;
|
|
151
|
+
|
|
152
|
+
export class CloudScriptProcessBase {
|
|
153
|
+
protected async sendEvent(event: CloudScriptEvent) {
|
|
154
|
+
if (process?.send)
|
|
155
|
+
process.send(event);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as axios from "axios";
|
|
2
|
+
|
|
3
|
+
export class CloudScriptHttp {
|
|
4
|
+
public async get<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, config?: axios.AxiosRequestConfig<D>): Promise<R> {
|
|
5
|
+
return await axios.default.get<T, R, D>(url, config);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
public async delete<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, config?: axios.AxiosRequestConfig<D>): Promise<R> {
|
|
9
|
+
return await axios.default.delete<T, R, D>(url, config);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public async head<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, config?: axios.AxiosRequestConfig<D>): Promise<R> {
|
|
13
|
+
return await axios.default.head<T, R, D>(url, config);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public async options<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, config?: axios.AxiosRequestConfig<D>): Promise<R> {
|
|
17
|
+
return await axios.default.options<T, R, D>(url, config);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public async post<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: any, config?: axios.AxiosRequestConfig<D>): Promise<R> {
|
|
21
|
+
return await axios.default.post<T, R, D>(url, data, config);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public async put<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: any, config?: axios.AxiosRequestConfig<D>): Promise<R> {
|
|
25
|
+
return await axios.default.put<T, R, D>(url, data, config);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public async patch<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: any, config?: axios.AxiosRequestConfig<D>): Promise<R> {
|
|
29
|
+
return await axios.default.patch<T, R, D>(url, data, config);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CloudScriptEventType, CloudScriptProcessBase } from "./CloudScriptEvent";
|
|
2
|
+
|
|
3
|
+
export class CloudScriptMail extends CloudScriptProcessBase {
|
|
4
|
+
public async send(email: string, subject: string, contentHtml: string) {
|
|
5
|
+
return await this.sendEvent({
|
|
6
|
+
eventType: CloudScriptEventType.SendMailToOne,
|
|
7
|
+
email: email,
|
|
8
|
+
mailData: {
|
|
9
|
+
subject: subject,
|
|
10
|
+
contentHtml: contentHtml,
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public async sendToMore(emails: string[], subject: string, contentHtml: string) {
|
|
16
|
+
return await this.sendEvent({
|
|
17
|
+
eventType: CloudScriptEventType.SendMailToMore,
|
|
18
|
+
emails: emails,
|
|
19
|
+
mailData: {
|
|
20
|
+
subject: subject,
|
|
21
|
+
contentHtml: contentHtml,
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MatchmakingTicketCanMatch, ServerDetail } from "./../../index";
|
|
2
|
+
import { CloudScriptEventType, CloudScriptProcessBase } from "./CloudScriptEvent";
|
|
3
|
+
|
|
4
|
+
export class CloudScriptMatchmaking extends CloudScriptProcessBase {
|
|
5
|
+
public async confirmServerDetail(gameId: string, matchmakingTicketCanMatch: MatchmakingTicketCanMatch, serverDetail: ServerDetail) {
|
|
6
|
+
return await this.sendEvent({
|
|
7
|
+
eventType: CloudScriptEventType.ConfirmServerDetail,
|
|
8
|
+
gameId: gameId,
|
|
9
|
+
matchmakingTicketCanMatch: matchmakingTicketCanMatch,
|
|
10
|
+
serverDetail: serverDetail,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { CloudScriptEventType, CloudScriptProcessBase } from "./CloudScriptEvent";
|
|
2
|
+
|
|
3
|
+
export class CloudScriptPushNotification extends CloudScriptProcessBase {
|
|
4
|
+
public async send(token: string, title: string, body: string, badge?: number, sound?: string, icon?: string, data?: { [k: string]: any }) {
|
|
5
|
+
return await this.sendEvent({
|
|
6
|
+
eventType: CloudScriptEventType.SendPushNotificationToOne,
|
|
7
|
+
token: token,
|
|
8
|
+
pushData: {
|
|
9
|
+
title: title,
|
|
10
|
+
body: body,
|
|
11
|
+
badge: badge,
|
|
12
|
+
sound: sound,
|
|
13
|
+
icon: icon,
|
|
14
|
+
data: data,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public async sendToMore(tokens: string[], title: string, body: string, badge?: number, sound?: string, icon?: string, data?: { [k: string]: any }) {
|
|
20
|
+
return await this.sendEvent({
|
|
21
|
+
eventType: CloudScriptEventType.SendPushNotificationToMore,
|
|
22
|
+
tokens: tokens,
|
|
23
|
+
pushData: {
|
|
24
|
+
title: title,
|
|
25
|
+
body: body,
|
|
26
|
+
badge: badge,
|
|
27
|
+
sound: sound,
|
|
28
|
+
icon: icon,
|
|
29
|
+
data: data,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public async sendToTopic(topic: string, title: string, body: string, badge?: number, sound?: string, icon?: string, data?: { [k: string]: any }) {
|
|
35
|
+
return await this.sendEvent({
|
|
36
|
+
eventType: CloudScriptEventType.SendPushNotificationToTopic,
|
|
37
|
+
topic: topic,
|
|
38
|
+
pushData: {
|
|
39
|
+
title: title,
|
|
40
|
+
body: body,
|
|
41
|
+
badge: badge,
|
|
42
|
+
sound: sound,
|
|
43
|
+
icon: icon,
|
|
44
|
+
data: data,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public async subscribeToTopic(tokens: string[], topic: string) {
|
|
50
|
+
return await this.sendEvent({
|
|
51
|
+
eventType: CloudScriptEventType.SubscribeToTopic,
|
|
52
|
+
tokens: tokens,
|
|
53
|
+
topic: topic,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public async unsubscribeFromTopic(tokens: string[], topic: string) {
|
|
58
|
+
return await this.sendEvent({
|
|
59
|
+
eventType: CloudScriptEventType.UnsubscribeFromTopic,
|
|
60
|
+
tokens: tokens,
|
|
61
|
+
topic: topic,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { OperationEvent } from "@xmobitea/gn-typescript-client";
|
|
2
|
+
import { CloudScriptEventType, CloudScriptProcessBase } from "./CloudScriptEvent";
|
|
3
|
+
|
|
4
|
+
export class CloudScriptSocket extends CloudScriptProcessBase {
|
|
5
|
+
public async sendEventTo(userId: string, operationEvent: OperationEvent): Promise<void> {
|
|
6
|
+
return await this.sendEvent({
|
|
7
|
+
eventType: CloudScriptEventType.SendEventToOne,
|
|
8
|
+
userId: userId,
|
|
9
|
+
operationEvent: {
|
|
10
|
+
eventCode: operationEvent.getEventCode(),
|
|
11
|
+
parameters: operationEvent.getParameters()?.toData() ?? null,
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public async sendEventToMoreUser(userIds: string[], operationEvent: OperationEvent): Promise<void> {
|
|
17
|
+
return await this.sendEvent({
|
|
18
|
+
eventType: CloudScriptEventType.SendEventToMore,
|
|
19
|
+
userIds: userIds,
|
|
20
|
+
operationEvent: {
|
|
21
|
+
eventCode: operationEvent.getEventCode(),
|
|
22
|
+
parameters: operationEvent.getParameters()?.toData() ?? null,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public async sendEventToAllPlayer(operationEvent: OperationEvent): Promise<void> {
|
|
28
|
+
return await this.sendEvent({
|
|
29
|
+
eventType: CloudScriptEventType.SendEventToAll,
|
|
30
|
+
operationEvent: {
|
|
31
|
+
eventCode: operationEvent.getEventCode(),
|
|
32
|
+
parameters: operationEvent.getParameters()?.toData() ?? null,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public async joinRoom(userId: string, roomId: string): Promise<void> {
|
|
38
|
+
return await this.sendEvent({
|
|
39
|
+
eventType: CloudScriptEventType.JoinRoom,
|
|
40
|
+
userId: userId,
|
|
41
|
+
roomId: roomId,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public async leaveRoom(userId: string, roomId: string): Promise<void> {
|
|
46
|
+
return await this.sendEvent({
|
|
47
|
+
eventType: CloudScriptEventType.LeaveRoom,
|
|
48
|
+
userId: userId,
|
|
49
|
+
roomId: roomId,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public async sendEventToRoom(roomId: string, operationEvent: OperationEvent): Promise<void> {
|
|
54
|
+
return await this.sendEvent({
|
|
55
|
+
eventType: CloudScriptEventType.SendEventToRoom,
|
|
56
|
+
roomId: roomId,
|
|
57
|
+
operationEvent: {
|
|
58
|
+
eventCode: operationEvent.getEventCode(),
|
|
59
|
+
parameters: operationEvent.getParameters()?.toData() ?? null,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
}
|
|
@@ -19,40 +19,82 @@
|
|
|
19
19
|
"eventName": "system_OnEveryDay",
|
|
20
20
|
"script": "\nsystemHandlers.system_OnEveryDay = async (log: (log: any) => void) => {\n\n}\n",
|
|
21
21
|
"hasEdit": false
|
|
22
|
-
}
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"type": "systemMatchmaking",
|
|
27
|
+
"version": "FIRSTVER",
|
|
28
|
+
"fullScript": "// first full script",
|
|
29
|
+
"tsLastUpdate": 1736498427663,
|
|
30
|
+
"childScripts": [
|
|
23
31
|
{
|
|
24
|
-
"eventName": "
|
|
25
|
-
"script": "\nsystemMatchmakingHandlers.
|
|
32
|
+
"eventName": "systemMatchmaking_RequestServerDetail",
|
|
33
|
+
"script": "\nsystemMatchmakingHandlers.systemMatchmaking_RequestServerDetail = async (gameId: string, matchmakingTicketCanMatch: MatchmakingTicketCanMatch, log: (log: any) => void): Promise<{ success: boolean }> => {\n\t//call matchmaking.confirmServerDetail(gameId, matchmakingTicketCanMatch, { ipV4Address: '127.0.0.1', ports: [{ name: 'GamePort', publicPort: 2202, privatePort: 3000, protocol: 1 }] }); // after setup success a dedicated server;\n\treturn { success: false };\n}\n",
|
|
26
34
|
"hasEdit": false
|
|
27
|
-
}
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"type": "systemAuthenticate",
|
|
40
|
+
"version": "FIRSTVER",
|
|
41
|
+
"fullScript": "// first full script",
|
|
42
|
+
"tsLastUpdate": 1736498427663,
|
|
43
|
+
"childScripts": [
|
|
28
44
|
{
|
|
29
|
-
"eventName": "
|
|
30
|
-
"script": "\nsystemAuthenticateHandlers.
|
|
45
|
+
"eventName": "systemAuthenticate_OnAuthenticateSuccess",
|
|
46
|
+
"script": "\nsystemAuthenticateHandlers.systemAuthenticate_OnAuthenticateSuccess = async (request: { userId: string, ipAddress: string, isNewUser: boolean, authenticationType: string }, secretInfo: SecretInfo, operationRequest: OperationRequest, operationResponse: OperationResponse, log: (log: any) => void) => {\n\n\treturn operationResponse;\n}\n",
|
|
31
47
|
"hasEdit": false
|
|
32
48
|
},
|
|
33
49
|
{
|
|
34
|
-
"eventName": "
|
|
35
|
-
"script": "\nsystemGenericServiceHandlers.
|
|
50
|
+
"eventName": "systemAuthenticate_VerifyGenericService",
|
|
51
|
+
"script": "\nsystemGenericServiceHandlers.systemAuthenticate_VerifyGenericService = async (serviceName: string, serviceData: { [k: string]: any; }, log: (log: any) => void): Promise<{ success: boolean, serviceId: string, someDatas?: any, errorMessage?: string }> => {\n\n\treturn { success: false, serviceId: null, };\n}\n",
|
|
52
|
+
"hasEdit": false
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"type": "event",
|
|
58
|
+
"version": "FIRSTVER",
|
|
59
|
+
"fullScript": "// first full script",
|
|
60
|
+
"tsLastUpdate": 1736498427663,
|
|
61
|
+
"childScripts": [
|
|
62
|
+
{
|
|
63
|
+
"eventName": "event_SendEventTo",
|
|
64
|
+
"script": "\neventHandlers.event_SendEventTo = async (request: { userId: string }, operationEvent: OperationEvent, log: (log: any) => void) => {\n\n}\n",
|
|
36
65
|
"hasEdit": false
|
|
37
66
|
},
|
|
38
67
|
{
|
|
39
|
-
"eventName": "
|
|
40
|
-
"script": "\neventHandlers.
|
|
68
|
+
"eventName": "event_SendEventToRoom",
|
|
69
|
+
"script": "\neventHandlers.event_SendEventToRoom = async (request: { roomId: string }, operationEvent: OperationEvent, log: (log: any) => void) => {\n\n}\n",
|
|
41
70
|
"hasEdit": false
|
|
42
71
|
},
|
|
43
72
|
{
|
|
44
|
-
"eventName": "
|
|
45
|
-
"script": "\neventHandlers.
|
|
73
|
+
"eventName": "event_SendEventToMoreUser",
|
|
74
|
+
"script": "\neventHandlers.event_SendEventToMoreUser = async (request: { userIds: string[] }, operationEvent: OperationEvent, log: (log: any) => void) => {\n\n}\n",
|
|
46
75
|
"hasEdit": false
|
|
47
76
|
},
|
|
48
77
|
{
|
|
49
|
-
"eventName": "
|
|
50
|
-
"script": "\neventHandlers.
|
|
78
|
+
"eventName": "event_SendEventToAllPlayer",
|
|
79
|
+
"script": "\neventHandlers.event_SendEventToAllPlayer = async (request: {}, operationEvent: OperationEvent, log: (log: any) => void) => {\n\n}\n",
|
|
80
|
+
"hasEdit": false
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"type": "socket",
|
|
86
|
+
"version": "FIRSTVER",
|
|
87
|
+
"fullScript": "// first full script",
|
|
88
|
+
"tsLastUpdate": 1736498427663,
|
|
89
|
+
"childScripts": [
|
|
90
|
+
{
|
|
91
|
+
"eventName": "socket_OnSocketConnected",
|
|
92
|
+
"script": "\nsocketHandlers.socket_OnSocketConnected = async (userId: string, socketId: string, log: (log: any) => void) => {\n\n}\n",
|
|
51
93
|
"hasEdit": false
|
|
52
94
|
},
|
|
53
95
|
{
|
|
54
|
-
"eventName": "
|
|
55
|
-
"script": "\
|
|
96
|
+
"eventName": "socket_OnSocketDisconnected",
|
|
97
|
+
"script": "\nsocketHandlers.socket_OnSocketDisconnected = async (userId: string, socketId: string, log: (log: any) => void) => {\n\n}\n",
|
|
56
98
|
"hasEdit": false
|
|
57
99
|
}
|
|
58
100
|
]
|
|
@@ -446,7 +488,7 @@
|
|
|
446
488
|
},
|
|
447
489
|
{
|
|
448
490
|
"eventName": "cloudScript_ExecuteFunction",
|
|
449
|
-
"script": "\npreHandlers.cloudScript_ExecuteFunction = async (request: { userId: string, functionName: string, functionParameters:
|
|
491
|
+
"script": "\npreHandlers.cloudScript_ExecuteFunction = async (request: { userId: string, functionName: string, functionParameters: any, version: string }, secretInfo: SecretInfo, operationRequest: OperationRequest, log: (log: any) => void) => {\n\n\treturn null;\n}\n\npostHandlers.cloudScript_ExecuteFunction = async (request: { userId: string, functionName: string, functionParameters: any, version: string }, secretInfo: SecretInfo, operationRequest: OperationRequest, operationResponse: OperationResponse, log: (log: any) => void) => {\n\n\treturn operationResponse;\n}\n",
|
|
450
492
|
"hasEdit": false
|
|
451
493
|
},
|
|
452
494
|
{
|