@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
|
@@ -148,412 +148,61 @@ import {
|
|
|
148
148
|
import * as mongodb from "mongodb";
|
|
149
149
|
import * as axios from "axios";
|
|
150
150
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
eventType: CloudScriptEventType;
|
|
159
|
-
operationEvent: {
|
|
160
|
-
eventCode: string;
|
|
161
|
-
parameters: {} | null;
|
|
162
|
-
};
|
|
163
|
-
receiver: string[] | string | null;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
class CloudScriptAdmin {
|
|
167
|
-
public readonly characterPlayer = GNNetwork.characterPlayer.admin;
|
|
168
|
-
public readonly content = GNNetwork.content.admin;
|
|
169
|
-
public readonly gamePlayer = GNNetwork.gamePlayer.admin;
|
|
170
|
-
public readonly group = GNNetwork.group.admin;
|
|
171
|
-
public readonly inventory = GNNetwork.inventory.admin;
|
|
172
|
-
public readonly masterPlayer = GNNetwork.masterPlayer.admin;
|
|
173
|
-
public readonly storeInventory = GNNetwork.storeInventory.admin;
|
|
174
|
-
public readonly multiplayer = GNNetwork.multiplayer.admin;
|
|
175
|
-
public readonly cloudScript = GNNetwork.cloudScript.admin;
|
|
176
|
-
public readonly dashboard = {
|
|
177
|
-
getAdminAccountList: GNNetwork.dashboard.getAdminAccountList,
|
|
178
|
-
getAdminAccountListAsync: GNNetwork.dashboard.getAdminAccountListAsync,
|
|
179
|
-
getGameInformation: GNNetwork.dashboard.getGameInformation,
|
|
180
|
-
getGameInformationAsync: GNNetwork.dashboard.getGameInformationAsync,
|
|
181
|
-
getGameList: GNNetwork.dashboard.getGameList,
|
|
182
|
-
getGameListAsync: GNNetwork.dashboard.getGameListAsync,
|
|
183
|
-
getMasterGameSettings: GNNetwork.dashboard.getMasterGameSettings,
|
|
184
|
-
getMasterGameSettingsAsync: GNNetwork.dashboard.getMasterGameSettingsAsync,
|
|
185
|
-
getSecretInfoInformation: GNNetwork.dashboard.getSecretInfoInformation,
|
|
186
|
-
getSecretInfoInformationAsync: GNNetwork.dashboard.getSecretInfoInformationAsync,
|
|
187
|
-
getSecretInfoList: GNNetwork.dashboard.getSecretInfoList,
|
|
188
|
-
getSecretInfoListAsync: GNNetwork.dashboard.getSecretInfoListAsync,
|
|
189
|
-
getServerLog: GNNetwork.dashboard.getServerLog,
|
|
190
|
-
getServerLogAsync: GNNetwork.dashboard.getServerLogAsync,
|
|
191
|
-
setGameInformation: GNNetwork.dashboard.setGameInformation,
|
|
192
|
-
setGameInformationAsync: GNNetwork.dashboard.setGameInformationAsync,
|
|
193
|
-
getUsernameAdminAccount: GNNetwork.dashboard.getUsernameAdminAccount,
|
|
194
|
-
getUsernameAdminAccountAsync: GNNetwork.dashboard.getUsernameAdminAccountAsync,
|
|
195
|
-
getAnalytics: GNNetwork.dashboard.getAnalytics,
|
|
196
|
-
getAnalyticsAsync: GNNetwork.dashboard.getAnalyticsAsync,
|
|
197
|
-
resetStatisticsLeaderboard: GNNetwork.dashboard.resetStatisticsLeaderboard,
|
|
198
|
-
resetStatisticsLeaderboardAsync: GNNetwork.dashboard.resetStatisticsLeaderboardAsync,
|
|
199
|
-
getBackupStatisticsLeaderboardVersion: GNNetwork.dashboard.getBackupStatisticsLeaderboardVersion,
|
|
200
|
-
getBackupStatisticsLeaderboardVersionAsync: GNNetwork.dashboard.getBackupStatisticsLeaderboardVersionAsync,
|
|
201
|
-
getServerGameData: GNNetwork.dashboard.getServerGameData,
|
|
202
|
-
getServerGameDataAsync: GNNetwork.dashboard.getServerGameDataAsync,
|
|
203
|
-
deleteInDatabase: GNNetwork.dashboard.deleteInDatabase,
|
|
204
|
-
deleteInDatabaseAsync: GNNetwork.dashboard.deleteInDatabaseAsync,
|
|
205
|
-
};
|
|
206
|
-
public send(
|
|
207
|
-
requestType: RequestType,
|
|
208
|
-
role: RequestRole,
|
|
209
|
-
request: OperationRequest,
|
|
210
|
-
onResponse: Action1<OperationResponse>,
|
|
211
|
-
overrideAuthToken: string,
|
|
212
|
-
overrideSecretKey: string,
|
|
213
|
-
customTags: GNHashtable
|
|
214
|
-
): void {
|
|
215
|
-
GNNetwork.sendViaHttp(requestType, role, request, onResponse, overrideAuthToken, overrideSecretKey, customTags);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
public sendAsync(
|
|
219
|
-
requestType: RequestType,
|
|
220
|
-
role: RequestRole,
|
|
221
|
-
request: OperationRequest,
|
|
222
|
-
overrideAuthToken: string,
|
|
223
|
-
overrideSecretKey: string,
|
|
224
|
-
customTags: GNHashtable
|
|
225
|
-
): Promise<OperationResponse> {
|
|
226
|
-
return GNNetwork.sendViaHttpAsync(requestType, role, request, overrideAuthToken, overrideSecretKey, customTags);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
class CloudScriptDatabase {
|
|
231
|
-
private static readonly DOT: string = ".";
|
|
232
|
-
private static readonly RUNTIME: string = "Runtime" + CloudScriptDatabase.DOT;
|
|
233
|
-
private static readonly META: string = "Meta" + CloudScriptDatabase.DOT;
|
|
234
|
-
private static readonly SYSTEM: string = "System" + CloudScriptDatabase.DOT;
|
|
235
|
-
|
|
236
|
-
private client: mongodb.MongoClient;
|
|
237
|
-
private db: mongodb.Db;
|
|
238
|
-
|
|
239
|
-
private logClient: mongodb.MongoClient;
|
|
240
|
-
private logDb: mongodb.Db;
|
|
241
|
-
|
|
242
|
-
init(url: string, dbName: string, logUrl: string, logDbName: string, options?: mongodb.MongoClientOptions): void {
|
|
243
|
-
this.client = new mongodb.MongoClient(url, options);
|
|
244
|
-
|
|
245
|
-
this.db = this.client.db(dbName);
|
|
246
|
-
|
|
247
|
-
if (!logUrl || logUrl == "" || logUrl == url) {
|
|
248
|
-
this.logClient = this.client;
|
|
249
|
-
this.logDb = this.db;
|
|
250
|
-
}
|
|
251
|
-
else {
|
|
252
|
-
this.logClient = new mongodb.MongoClient(logUrl, options);
|
|
253
|
-
this.logDb = this.logClient.db(logDbName);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
public runtimeCollection<TSchema extends mongodb.Document = mongodb.Document>(collectionName: string): mongodb.Collection<TSchema> {
|
|
258
|
-
return this.collection<TSchema>(CloudScriptDatabase.RUNTIME + collectionName);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
public metaCollection<TSchema extends mongodb.Document = mongodb.Document>(collectionName: string): mongodb.Collection<TSchema> {
|
|
262
|
-
return this.collection<TSchema>(CloudScriptDatabase.META + collectionName);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
public systemCollection<TSchema extends mongodb.Document = mongodb.Document>(collectionName: string): mongodb.Collection<TSchema> {
|
|
266
|
-
return this.collection<TSchema>(CloudScriptDatabase.SYSTEM + collectionName);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
public runtimeGameCollection<TSchema extends mongodb.Document = mongodb.Document>(collectionName: string, gameId: string): mongodb.Collection<TSchema> {
|
|
270
|
-
return this.collection<TSchema>(CloudScriptDatabase.RUNTIME + gameId + CloudScriptDatabase.DOT + collectionName);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
public metaGameCollection<TSchema extends mongodb.Document = mongodb.Document>(collectionName: string, gameId: string): mongodb.Collection<TSchema> {
|
|
274
|
-
return this.collection<TSchema>(CloudScriptDatabase.META + gameId + CloudScriptDatabase.DOT + collectionName);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
public systemGameCollection<TSchema extends mongodb.Document = mongodb.Document>(collectionName: string, gameId: string): mongodb.Collection<TSchema> {
|
|
278
|
-
return this.collection<TSchema>(CloudScriptDatabase.SYSTEM + gameId + CloudScriptDatabase.DOT + collectionName);
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
public collection<TSchema extends mongodb.Document = mongodb.Document>(fullCollectionName: string): mongodb.Collection<TSchema> {
|
|
282
|
-
return this.db.collection<TSchema>(fullCollectionName);
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
public createCollection(name: string, options?: mongodb.CreateCollectionOptions): Promise<mongodb.Collection<mongodb.BSON.Document>> {
|
|
286
|
-
return this.db.createCollection(name, options);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
public logRuntimeCollection<TSchema extends mongodb.Document = mongodb.Document>(collectionName: string): mongodb.Collection<TSchema> {
|
|
290
|
-
return this.logCollection<TSchema>(CloudScriptDatabase.RUNTIME + collectionName);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
public logMetaCollection<TSchema extends mongodb.Document = mongodb.Document>(collectionName: string): mongodb.Collection<TSchema> {
|
|
294
|
-
return this.logCollection<TSchema>(CloudScriptDatabase.META + collectionName);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
public logSystemCollection<TSchema extends mongodb.Document = mongodb.Document>(collectionName: string): mongodb.Collection<TSchema> {
|
|
298
|
-
return this.logCollection<TSchema>(CloudScriptDatabase.SYSTEM + collectionName);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
public logRuntimeGameCollection<TSchema extends mongodb.Document = mongodb.Document>(collectionName: string, gameId: string): mongodb.Collection<TSchema> {
|
|
302
|
-
return this.logCollection<TSchema>(CloudScriptDatabase.RUNTIME + gameId + CloudScriptDatabase.DOT + collectionName);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
public logMetaGameCollection<TSchema extends mongodb.Document = mongodb.Document>(collectionName: string, gameId: string): mongodb.Collection<TSchema> {
|
|
306
|
-
return this.logCollection<TSchema>(CloudScriptDatabase.META + gameId + CloudScriptDatabase.DOT + collectionName);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
public logSystemGameCollection<TSchema extends mongodb.Document = mongodb.Document>(collectionName: string, gameId: string): mongodb.Collection<TSchema> {
|
|
310
|
-
return this.logCollection<TSchema>(CloudScriptDatabase.SYSTEM + gameId + CloudScriptDatabase.DOT + collectionName);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
public logCollection<TSchema extends mongodb.Document = mongodb.Document>(fullCollectionName: string): mongodb.Collection<TSchema> {
|
|
314
|
-
return this.logDb.collection<TSchema>(fullCollectionName);
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
public logCreateCollection<TSchema extends mongodb.Document = mongodb.Document>(collectionName: string, options?: mongodb.CreateCollectionOptions) {
|
|
318
|
-
return this.logDb.createCollection<TSchema>(collectionName, options)
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
class CloudScriptHttp {
|
|
323
|
-
public async get<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, config?: axios.AxiosRequestConfig<D>): Promise<R> {
|
|
324
|
-
return await axios.default.get<T, R, D>(url, config);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
public async delete<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, config?: axios.AxiosRequestConfig<D>): Promise<R> {
|
|
328
|
-
return await axios.default.delete<T, R, D>(url, config);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
public async head<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, config?: axios.AxiosRequestConfig<D>): Promise<R> {
|
|
332
|
-
return await axios.default.head<T, R, D>(url, config);
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
public async options<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, config?: axios.AxiosRequestConfig<D>): Promise<R> {
|
|
336
|
-
return await axios.default.options<T, R, D>(url, config);
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
public async post<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: any, config?: axios.AxiosRequestConfig<D>): Promise<R> {
|
|
340
|
-
return await axios.default.post<T, R, D>(url, data, config);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
public async put<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: any, config?: axios.AxiosRequestConfig<D>): Promise<R> {
|
|
344
|
-
return await axios.default.put<T, R, D>(url, data, config);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
public async patch<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: any, config?: axios.AxiosRequestConfig<D>): Promise<R> {
|
|
348
|
-
return await axios.default.patch<T, R, D>(url, data, config);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
class CloudScriptSocket {
|
|
353
|
-
public async sendEventTo(userId: string, operationEvent: OperationEvent): Promise<void> {
|
|
354
|
-
return await this.sendEvent({
|
|
355
|
-
eventType: CloudScriptEventType.SendToUser,
|
|
356
|
-
receiver: userId,
|
|
357
|
-
operationEvent: {
|
|
358
|
-
eventCode: operationEvent.getEventCode(),
|
|
359
|
-
parameters: operationEvent.getParameters()?.toData() ?? null,
|
|
360
|
-
},
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
public async sendEventToMoreUser(userIds: string[], operationEvent: OperationEvent): Promise<void> {
|
|
365
|
-
return await this.sendEvent({
|
|
366
|
-
eventType: CloudScriptEventType.SendToMore,
|
|
367
|
-
receiver: userIds,
|
|
368
|
-
operationEvent: {
|
|
369
|
-
eventCode: operationEvent.getEventCode(),
|
|
370
|
-
parameters: operationEvent.getParameters()?.toData() ?? null,
|
|
371
|
-
},
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
public async sendEventToAllPlayer(operationEvent: OperationEvent): Promise<void> {
|
|
376
|
-
return await this.sendEvent({
|
|
377
|
-
eventType: CloudScriptEventType.SendToAll,
|
|
378
|
-
receiver: null,
|
|
379
|
-
operationEvent: {
|
|
380
|
-
eventCode: operationEvent.getEventCode(),
|
|
381
|
-
parameters: operationEvent.getParameters()?.toData() ?? null,
|
|
382
|
-
},
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
private async sendEvent(event: CloudScriptEvent) {
|
|
387
|
-
if (process?.send)
|
|
388
|
-
process.send(event);
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
class CloudScriptMatchmaking {
|
|
393
|
-
public async confirmServerDetail(gameId: string, matchmakingTicketCanMatch: MatchmakingTicketCanMatch, serverDetail: ServerDetail) {
|
|
394
|
-
if (process?.send)
|
|
395
|
-
process.send({
|
|
396
|
-
eventType: 10,
|
|
397
|
-
receiver: null,
|
|
398
|
-
operationEvent: {
|
|
399
|
-
eventCode: 0,
|
|
400
|
-
parameters: {
|
|
401
|
-
gameId: gameId,
|
|
402
|
-
matchmakingTicketCanMatch: matchmakingTicketCanMatch,
|
|
403
|
-
serverDetail: serverDetail,
|
|
404
|
-
},
|
|
405
|
-
},
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
class CloudScriptMail {
|
|
411
|
-
public async send(email: string, subject: string, contentHtml: string) {
|
|
412
|
-
if (process?.send)
|
|
413
|
-
process.send({
|
|
414
|
-
eventType: 20,
|
|
415
|
-
receiver: null,
|
|
416
|
-
operationEvent: {
|
|
417
|
-
eventCode: 0,
|
|
418
|
-
parameters: {
|
|
419
|
-
email: email,
|
|
420
|
-
subject: subject,
|
|
421
|
-
contentHtml: contentHtml,
|
|
422
|
-
},
|
|
423
|
-
},
|
|
424
|
-
});
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
public async sendToMore(emails: string[], subject: string, contentHtml: string) {
|
|
428
|
-
if (process?.send)
|
|
429
|
-
process.send({
|
|
430
|
-
eventType: 21,
|
|
431
|
-
receiver: null,
|
|
432
|
-
operationEvent: {
|
|
433
|
-
eventCode: 0,
|
|
434
|
-
parameters: {
|
|
435
|
-
emails: emails,
|
|
436
|
-
subject: subject,
|
|
437
|
-
contentHtml: contentHtml,
|
|
438
|
-
},
|
|
439
|
-
},
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
class CloudScriptPushNotification {
|
|
445
|
-
public async send(token: string, title: string, body: string, badge?: number, sound?: string, icon?: string, data?: { [k: string]: any }) {
|
|
446
|
-
if (process?.send)
|
|
447
|
-
process.send({
|
|
448
|
-
eventType: 30,
|
|
449
|
-
receiver: null,
|
|
450
|
-
operationEvent: {
|
|
451
|
-
eventCode: 0,
|
|
452
|
-
parameters: {
|
|
453
|
-
token: token,
|
|
454
|
-
title: title,
|
|
455
|
-
body: body,
|
|
456
|
-
badge: badge,
|
|
457
|
-
sound: sound,
|
|
458
|
-
icon: icon,
|
|
459
|
-
data: data,
|
|
460
|
-
},
|
|
461
|
-
},
|
|
462
|
-
});
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
public async sendToMore(tokens: string[], title: string, body: string, badge?: number, sound?: string, icon?: string, data?: { [k: string]: any }) {
|
|
466
|
-
if (process?.send)
|
|
467
|
-
process.send({
|
|
468
|
-
eventType: 31,
|
|
469
|
-
receiver: null,
|
|
470
|
-
operationEvent: {
|
|
471
|
-
eventCode: 0,
|
|
472
|
-
parameters: {
|
|
473
|
-
tokens: tokens,
|
|
474
|
-
title: title,
|
|
475
|
-
body: body,
|
|
476
|
-
badge: badge,
|
|
477
|
-
sound: sound,
|
|
478
|
-
icon: icon,
|
|
479
|
-
data: data,
|
|
480
|
-
},
|
|
481
|
-
},
|
|
482
|
-
});
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
public async sendToTopic(topic: string, title: string, body: string, badge?: number, sound?: string, icon?: string, data?: { [k: string]: any }) {
|
|
486
|
-
if (process?.send)
|
|
487
|
-
process.send({
|
|
488
|
-
eventType: 32,
|
|
489
|
-
receiver: null,
|
|
490
|
-
operationEvent: {
|
|
491
|
-
eventCode: 0,
|
|
492
|
-
parameters: {
|
|
493
|
-
topic: topic,
|
|
494
|
-
title: title,
|
|
495
|
-
body: body,
|
|
496
|
-
badge: badge,
|
|
497
|
-
sound: sound,
|
|
498
|
-
icon: icon,
|
|
499
|
-
data: data,
|
|
500
|
-
},
|
|
501
|
-
},
|
|
502
|
-
});
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
public async subscribeToTopic(tokens: string[], topic: string) {
|
|
506
|
-
if (process?.send)
|
|
507
|
-
process.send({
|
|
508
|
-
eventType: 33,
|
|
509
|
-
receiver: null,
|
|
510
|
-
operationEvent: {
|
|
511
|
-
eventCode: 0,
|
|
512
|
-
parameters: {
|
|
513
|
-
tokens: tokens,
|
|
514
|
-
topic: topic,
|
|
515
|
-
},
|
|
516
|
-
},
|
|
517
|
-
});
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
public async unsubscribeFromTopic(tokens: string[], topic: string) {
|
|
521
|
-
if (process?.send)
|
|
522
|
-
process.send({
|
|
523
|
-
eventType: 34,
|
|
524
|
-
receiver: null,
|
|
525
|
-
operationEvent: {
|
|
526
|
-
eventCode: 0,
|
|
527
|
-
parameters: {
|
|
528
|
-
tokens: tokens,
|
|
529
|
-
topic: topic,
|
|
530
|
-
},
|
|
531
|
-
},
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
}
|
|
151
|
+
import { CloudScriptAdmin } from "./CloudScriptAdmin";
|
|
152
|
+
import { CloudScriptDatabase } from "./CloudScriptDatabase";
|
|
153
|
+
import { CloudScriptHttp } from "./CloudScriptHttp";
|
|
154
|
+
import { CloudScriptSocket } from "./CloudScriptSocket";
|
|
155
|
+
import { CloudScriptMatchmaking } from "./CloudScriptMatchmaking";
|
|
156
|
+
import { CloudScriptMail } from "./CloudScriptMail";
|
|
157
|
+
import { CloudScriptPushNotification } from "./CloudScriptPushNotification";
|
|
535
158
|
|
|
536
159
|
enum EventCallbackType {
|
|
537
160
|
Pre = 0,
|
|
538
161
|
Post = 1,
|
|
539
162
|
System = 2,
|
|
540
|
-
|
|
163
|
+
SystemMatchmaking = 3,
|
|
164
|
+
SystemAuthenticate = 5,
|
|
165
|
+
Event = 6,
|
|
166
|
+
Socket = 7,
|
|
541
167
|
}
|
|
542
168
|
|
|
543
|
-
interface
|
|
169
|
+
interface CloudScriptRequestPre {
|
|
544
170
|
requestId: string;
|
|
545
|
-
eventType: EventCallbackType;
|
|
171
|
+
eventType: EventCallbackType.Pre;
|
|
546
172
|
eventName: string;
|
|
547
173
|
request: { [k: string]: any };
|
|
548
174
|
secretInfo: {
|
|
549
175
|
secretKey: string;
|
|
176
|
+
description: string;
|
|
550
177
|
role: number;
|
|
551
178
|
remove: boolean;
|
|
552
179
|
tsExpire: number;
|
|
553
180
|
permission: SecretPermissionItem;
|
|
554
181
|
gameId: string;
|
|
555
182
|
isDefault: boolean;
|
|
183
|
+
onlyMasterAdmin: boolean;
|
|
184
|
+
};
|
|
185
|
+
operationRequest: {
|
|
186
|
+
operationCode: string;
|
|
187
|
+
requestId: number;
|
|
188
|
+
parameters: {};
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
interface CloudScriptRequestPost {
|
|
193
|
+
requestId: string;
|
|
194
|
+
eventType: EventCallbackType.Post;
|
|
195
|
+
eventName: string;
|
|
196
|
+
request: { [k: string]: any };
|
|
197
|
+
secretInfo: {
|
|
198
|
+
secretKey: string;
|
|
556
199
|
description: string;
|
|
200
|
+
role: number;
|
|
201
|
+
remove: boolean;
|
|
202
|
+
tsExpire: number;
|
|
203
|
+
permission: SecretPermissionItem;
|
|
204
|
+
gameId: string;
|
|
205
|
+
isDefault: boolean;
|
|
557
206
|
onlyMasterAdmin: boolean;
|
|
558
207
|
};
|
|
559
208
|
operationRequest: {
|
|
@@ -561,14 +210,77 @@ interface CloudScriptRequest {
|
|
|
561
210
|
requestId: number;
|
|
562
211
|
parameters: {};
|
|
563
212
|
};
|
|
213
|
+
operationResponse: {
|
|
214
|
+
returnCode: number;
|
|
215
|
+
debugMessage: string;
|
|
216
|
+
parameters: {};
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
interface CloudScriptRequestSystem {
|
|
221
|
+
requestId: string;
|
|
222
|
+
eventType: EventCallbackType.System;
|
|
223
|
+
eventName: string;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
interface CloudScriptRequestSystemMatchmaking {
|
|
227
|
+
requestId: string;
|
|
228
|
+
eventType: EventCallbackType.SystemMatchmaking;
|
|
229
|
+
eventName: string;
|
|
230
|
+
request: {
|
|
231
|
+
gameId: string;
|
|
232
|
+
matchmakingTicketCanMatch: MatchmakingTicketCanMatch;
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
interface CloudScriptRequestSystemAuthenticate {
|
|
237
|
+
requestId: string;
|
|
238
|
+
eventType: EventCallbackType.SystemAuthenticate;
|
|
239
|
+
eventName: string;
|
|
240
|
+
request: { [k: string]: any };
|
|
241
|
+
operationRequest?: {
|
|
242
|
+
operationCode: string;
|
|
243
|
+
requestId: number;
|
|
244
|
+
parameters: {};
|
|
245
|
+
};
|
|
564
246
|
operationResponse?: {
|
|
565
247
|
returnCode: number;
|
|
566
248
|
debugMessage: string;
|
|
567
249
|
parameters: {};
|
|
568
250
|
};
|
|
569
|
-
|
|
251
|
+
secretInfo?: {
|
|
252
|
+
secretKey: string;
|
|
253
|
+
description: string;
|
|
254
|
+
role: number;
|
|
255
|
+
remove: boolean;
|
|
256
|
+
tsExpire: number;
|
|
257
|
+
permission: SecretPermissionItem;
|
|
258
|
+
gameId: string;
|
|
259
|
+
isDefault: boolean;
|
|
260
|
+
onlyMasterAdmin: boolean;
|
|
261
|
+
};
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
interface CloudScriptRequestEvent {
|
|
265
|
+
requestId: string;
|
|
266
|
+
eventType: EventCallbackType.Event;
|
|
267
|
+
eventName: string;
|
|
268
|
+
request: { [k: string]: any };
|
|
269
|
+
operationEvent: {
|
|
270
|
+
eventCode: string;
|
|
271
|
+
parameters: {};
|
|
272
|
+
};
|
|
570
273
|
}
|
|
571
274
|
|
|
275
|
+
interface CloudScriptRequestSocket {
|
|
276
|
+
requestId: string;
|
|
277
|
+
eventType: EventCallbackType.Socket;
|
|
278
|
+
eventName: string;
|
|
279
|
+
request: { [k: string]: any };
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
type CloudScriptRequest = CloudScriptRequestPre | CloudScriptRequestPost | CloudScriptRequestSystem | CloudScriptRequestSystemMatchmaking | CloudScriptRequestSystemAuthenticate | CloudScriptRequestEvent | CloudScriptRequestSocket;
|
|
283
|
+
|
|
572
284
|
interface CloudScriptResponse {
|
|
573
285
|
stats: {
|
|
574
286
|
memoryUsedInBytes: number;
|
|
@@ -579,12 +291,60 @@ interface CloudScriptResponse {
|
|
|
579
291
|
logs: string[];
|
|
580
292
|
}
|
|
581
293
|
|
|
582
|
-
interface
|
|
583
|
-
eventName: string;
|
|
294
|
+
interface FunctionRequestPre {
|
|
584
295
|
request: { [k: string]: any };
|
|
585
296
|
secretInfo: SecretInfo;
|
|
586
297
|
operationRequest: OperationRequest;
|
|
587
|
-
|
|
298
|
+
log: (log: any) => void;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
interface FunctionRequestPost {
|
|
302
|
+
request: { [k: string]: any };
|
|
303
|
+
secretInfo: SecretInfo;
|
|
304
|
+
operationRequest: OperationRequest;
|
|
305
|
+
operationResponse: OperationResponse;
|
|
306
|
+
log: (log: any) => void;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
interface FunctionRequestSystem {
|
|
310
|
+
log: (log: any) => void;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
interface FunctionRequestEvent {
|
|
314
|
+
request: { [k: string]: any };
|
|
315
|
+
operationEvent: OperationEvent;
|
|
316
|
+
log: (log: any) => void;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
interface FunctionRequestSystemMatchmaking {
|
|
320
|
+
request: { gameId: string, matchmakingTicketCanMatch: MatchmakingTicketCanMatch };
|
|
321
|
+
log: (log: any) => void;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
interface FunctionRequestSystemAuthenticate {
|
|
325
|
+
request: { [k: string]: any };
|
|
326
|
+
secretInfo: SecretInfo;
|
|
327
|
+
operationRequest: OperationRequest;
|
|
328
|
+
operationResponse: OperationResponse;
|
|
329
|
+
log: (log: any) => void;
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
interface FunctionRequestSystemVerifyGenericService {
|
|
333
|
+
request: {
|
|
334
|
+
serviceName: string;
|
|
335
|
+
serviceData: {
|
|
336
|
+
[k: string]: any;
|
|
337
|
+
};
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
log: (log: any) => void;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
interface FunctionRequestSocket {
|
|
344
|
+
request: {
|
|
345
|
+
[k: string]: any;
|
|
346
|
+
};
|
|
347
|
+
|
|
588
348
|
log: (log: any) => void;
|
|
589
349
|
}
|
|
590
350
|
|
|
@@ -600,6 +360,9 @@ interface FunctionResponse {
|
|
|
600
360
|
returnCode: number;
|
|
601
361
|
debugMessage: string;
|
|
602
362
|
parameters?: {};
|
|
363
|
+
} | {
|
|
364
|
+
eventCode: string;
|
|
365
|
+
parameters?: {};
|
|
603
366
|
} | null;
|
|
604
367
|
request: {
|
|
605
368
|
[k: string]: any;
|
|
@@ -616,33 +379,103 @@ process?.on("message", async (request: CloudScriptRequest) => {
|
|
|
616
379
|
let handleResponse: FunctionResponse = null as any;
|
|
617
380
|
|
|
618
381
|
if (request.eventType == EventCallbackType.System) {
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
382
|
+
let functionRequest: FunctionRequestSystem = {
|
|
383
|
+
log(log: any) {
|
|
384
|
+
logs.push(JSON.stringify(log));
|
|
385
|
+
},
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
handleResponse = await ___handleSystemFunction(request.eventName, functionRequest);
|
|
389
|
+
}
|
|
390
|
+
else if (request.eventType == EventCallbackType.Pre || request.eventType == EventCallbackType.Post) {
|
|
391
|
+
let originOperationRequest = request.operationRequest;
|
|
392
|
+
let operationRequest = new OperationRequest(originOperationRequest.operationCode);
|
|
393
|
+
if (originOperationRequest.parameters) {
|
|
394
|
+
operationRequest.setParameters(GNHashtable.builder().addAll(originOperationRequest.parameters).build());
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
let originSecretInfo = request.secretInfo;
|
|
398
|
+
let secretInfo: SecretInfo = null as any;
|
|
399
|
+
if (originSecretInfo) {
|
|
400
|
+
secretInfo = SecretInfo.Builder()
|
|
401
|
+
.setSecretKey(originSecretInfo.secretKey)
|
|
402
|
+
.setDescription(originSecretInfo.description)
|
|
403
|
+
.setRole(originSecretInfo.role)
|
|
404
|
+
.setIsRemove(originSecretInfo.remove)
|
|
405
|
+
.setTsExpire(originSecretInfo.tsExpire)
|
|
406
|
+
.setPermission(originSecretInfo.permission)
|
|
407
|
+
.setGameId(originSecretInfo.gameId)
|
|
408
|
+
.setIsDefault(originSecretInfo.isDefault)
|
|
409
|
+
.setIsOnlyMasterAdmin(originSecretInfo.onlyMasterAdmin)
|
|
410
|
+
.build();
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
if (request.eventType == EventCallbackType.Pre) {
|
|
414
|
+
let functionRequest: FunctionRequestPre = {
|
|
415
|
+
operationRequest: operationRequest,
|
|
416
|
+
secretInfo: secretInfo,
|
|
624
417
|
request: request.request,
|
|
625
418
|
log(log: any) {
|
|
626
419
|
logs.push(JSON.stringify(log));
|
|
627
420
|
},
|
|
628
421
|
};
|
|
629
422
|
|
|
630
|
-
handleResponse = await
|
|
423
|
+
handleResponse = await ___handlePreFunction(request.eventName, functionRequest);
|
|
631
424
|
}
|
|
632
|
-
else if (request.
|
|
633
|
-
let
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
425
|
+
else if (request.eventType == EventCallbackType.Post) {
|
|
426
|
+
let originOperationResponse = request.operationResponse;
|
|
427
|
+
let operationResponse: OperationResponse = null as any;
|
|
428
|
+
|
|
429
|
+
if (originOperationResponse) {
|
|
430
|
+
operationResponse = new OperationResponse(originOperationRequest.operationCode, originOperationRequest.requestId);
|
|
431
|
+
operationResponse.setReturnCode(originOperationResponse.returnCode);
|
|
432
|
+
operationResponse.setDebugMessage(originOperationResponse.debugMessage);
|
|
433
|
+
|
|
434
|
+
if (originOperationResponse.parameters) {
|
|
435
|
+
operationResponse.setParameters(GNHashtable.builder().addAll(originOperationResponse.parameters).build());
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
let functionRequest: FunctionRequestPost = {
|
|
440
|
+
operationRequest: operationRequest,
|
|
441
|
+
operationResponse: operationResponse,
|
|
442
|
+
secretInfo: secretInfo,
|
|
637
443
|
request: request.request,
|
|
638
444
|
log(log: any) {
|
|
639
445
|
logs.push(JSON.stringify(log));
|
|
640
446
|
},
|
|
641
447
|
};
|
|
642
448
|
|
|
643
|
-
handleResponse = await
|
|
449
|
+
handleResponse = await ___handlePostFunction(request.eventName, functionRequest);
|
|
644
450
|
}
|
|
645
|
-
|
|
451
|
+
}
|
|
452
|
+
else if (request.eventType == EventCallbackType.Event) {
|
|
453
|
+
let originOperationEvent = request.operationEvent;
|
|
454
|
+
|
|
455
|
+
let operationEvent = new OperationEvent(originOperationEvent.eventCode, (originOperationEvent.parameters ? GNHashtable.builder().addAll(originOperationEvent.parameters).build() : null as any));
|
|
456
|
+
|
|
457
|
+
let functionRequest: FunctionRequestEvent = {
|
|
458
|
+
operationEvent: operationEvent,
|
|
459
|
+
request: request.request,
|
|
460
|
+
log(log: any) {
|
|
461
|
+
logs.push(JSON.stringify(log));
|
|
462
|
+
},
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
handleResponse = await ___handleEventFunction(request.eventName, functionRequest);
|
|
466
|
+
}
|
|
467
|
+
else if (request.eventType == EventCallbackType.SystemMatchmaking) {
|
|
468
|
+
let functionRequest: FunctionRequestSystemMatchmaking = {
|
|
469
|
+
request: request.request,
|
|
470
|
+
log(log: any) {
|
|
471
|
+
logs.push(JSON.stringify(log));
|
|
472
|
+
},
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
handleResponse = await ___handleSystemMatchmakingFunction(request.eventName, functionRequest);
|
|
476
|
+
}
|
|
477
|
+
else if (request.eventType == EventCallbackType.SystemAuthenticate) {
|
|
478
|
+
if (request.operationRequest != null) {
|
|
646
479
|
let originOperationRequest = request.operationRequest;
|
|
647
480
|
let operationRequest = new OperationRequest(originOperationRequest.operationCode);
|
|
648
481
|
if (originOperationRequest.parameters) {
|
|
@@ -678,8 +511,7 @@ process?.on("message", async (request: CloudScriptRequest) => {
|
|
|
678
511
|
}
|
|
679
512
|
}
|
|
680
513
|
|
|
681
|
-
let functionRequest:
|
|
682
|
-
eventName: request.eventName,
|
|
514
|
+
let functionRequest: FunctionRequestSystemAuthenticate = {
|
|
683
515
|
operationRequest: operationRequest,
|
|
684
516
|
operationResponse: operationResponse,
|
|
685
517
|
secretInfo: secretInfo,
|
|
@@ -689,102 +521,31 @@ process?.on("message", async (request: CloudScriptRequest) => {
|
|
|
689
521
|
},
|
|
690
522
|
};
|
|
691
523
|
|
|
692
|
-
handleResponse = await ___handleSystemAuthenticateFunction(functionRequest);
|
|
524
|
+
handleResponse = await ___handleSystemAuthenticateFunction(request.eventName, functionRequest);
|
|
693
525
|
}
|
|
694
526
|
else {
|
|
695
|
-
let functionRequest:
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
527
|
+
let functionRequest: FunctionRequestSystemVerifyGenericService = {
|
|
528
|
+
request: {
|
|
529
|
+
serviceData: request.request.serviceData,
|
|
530
|
+
serviceName: request.request.serviceName,
|
|
531
|
+
},
|
|
700
532
|
log(log: any) {
|
|
701
533
|
logs.push(JSON.stringify(log));
|
|
702
534
|
},
|
|
703
535
|
};
|
|
704
536
|
|
|
705
|
-
handleResponse = await
|
|
537
|
+
handleResponse = await ___handleSystemGenericServiceFunction(request.eventName, functionRequest);
|
|
706
538
|
}
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
let functionRequest: FunctionRequest = {
|
|
713
|
-
eventName: request.eventName,
|
|
714
|
-
operationRequest: null as any,
|
|
715
|
-
secretInfo: null as any,
|
|
716
|
-
request: {
|
|
717
|
-
operationEvent: operationEvent,
|
|
718
|
-
request: request.request,
|
|
719
|
-
},
|
|
539
|
+
}
|
|
540
|
+
else if (request.eventType == EventCallbackType.Socket) {
|
|
541
|
+
let functionRequest: FunctionRequestSocket = {
|
|
542
|
+
request: request.request,
|
|
720
543
|
log(log: any) {
|
|
721
544
|
logs.push(JSON.stringify(log));
|
|
722
545
|
},
|
|
723
546
|
};
|
|
724
547
|
|
|
725
|
-
handleResponse = await
|
|
726
|
-
} else {
|
|
727
|
-
let originOperationRequest = request.operationRequest;
|
|
728
|
-
let operationRequest = new OperationRequest(originOperationRequest.operationCode);
|
|
729
|
-
if (originOperationRequest.parameters) {
|
|
730
|
-
operationRequest.setParameters(GNHashtable.builder().addAll(originOperationRequest.parameters).build());
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
let originSecretInfo = request.secretInfo;
|
|
734
|
-
let secretInfo: SecretInfo = null as any;
|
|
735
|
-
if (originSecretInfo) {
|
|
736
|
-
secretInfo = SecretInfo.Builder()
|
|
737
|
-
.setSecretKey(originSecretInfo.secretKey)
|
|
738
|
-
.setDescription(originSecretInfo.description)
|
|
739
|
-
.setRole(originSecretInfo.role)
|
|
740
|
-
.setIsRemove(originSecretInfo.remove)
|
|
741
|
-
.setTsExpire(originSecretInfo.tsExpire)
|
|
742
|
-
.setPermission(originSecretInfo.permission)
|
|
743
|
-
.setGameId(originSecretInfo.gameId)
|
|
744
|
-
.setIsDefault(originSecretInfo.isDefault)
|
|
745
|
-
.setIsOnlyMasterAdmin(originSecretInfo.onlyMasterAdmin)
|
|
746
|
-
.build();
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
if (request.eventType == EventCallbackType.Pre) {
|
|
750
|
-
let functionRequest: FunctionRequest = {
|
|
751
|
-
eventName: request.eventName,
|
|
752
|
-
operationRequest: operationRequest,
|
|
753
|
-
secretInfo: secretInfo,
|
|
754
|
-
request: request.request,
|
|
755
|
-
log(log: any) {
|
|
756
|
-
logs.push(JSON.stringify(log));
|
|
757
|
-
},
|
|
758
|
-
};
|
|
759
|
-
|
|
760
|
-
handleResponse = await ___handlePreFunction(functionRequest);
|
|
761
|
-
} else if (request.eventType == EventCallbackType.Post) {
|
|
762
|
-
let originOperationResponse = request.operationResponse;
|
|
763
|
-
let operationResponse: OperationResponse = null as any;
|
|
764
|
-
|
|
765
|
-
if (originOperationResponse) {
|
|
766
|
-
operationResponse = new OperationResponse(originOperationRequest.operationCode, originOperationRequest.requestId);
|
|
767
|
-
operationResponse.setReturnCode(originOperationResponse.returnCode);
|
|
768
|
-
operationResponse.setDebugMessage(originOperationResponse.debugMessage);
|
|
769
|
-
|
|
770
|
-
if (originOperationResponse.parameters) {
|
|
771
|
-
operationResponse.setParameters(GNHashtable.builder().addAll(originOperationResponse.parameters).build());
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
let functionRequest: FunctionRequest = {
|
|
776
|
-
eventName: request.eventName,
|
|
777
|
-
operationRequest: operationRequest,
|
|
778
|
-
operationResponse: operationResponse,
|
|
779
|
-
secretInfo: secretInfo,
|
|
780
|
-
request: request.request,
|
|
781
|
-
log(log: any) {
|
|
782
|
-
logs.push(JSON.stringify(log));
|
|
783
|
-
},
|
|
784
|
-
};
|
|
785
|
-
|
|
786
|
-
handleResponse = await ___handlePostFunction(functionRequest);
|
|
787
|
-
}
|
|
548
|
+
handleResponse = await ___handleSocketFunction(request.eventName, functionRequest);
|
|
788
549
|
}
|
|
789
550
|
|
|
790
551
|
let endTime = performance.now();
|
|
@@ -810,8 +571,8 @@ process?.on("message", async (request: CloudScriptRequest) => {
|
|
|
810
571
|
process.send(response);
|
|
811
572
|
});
|
|
812
573
|
|
|
813
|
-
async function
|
|
814
|
-
let handler = systemMatchmakingHandlers[
|
|
574
|
+
async function ___handleSystemMatchmakingFunction(name: string, request: FunctionRequestSystemMatchmaking): Promise<FunctionResponse> {
|
|
575
|
+
let handler = systemMatchmakingHandlers[name];
|
|
815
576
|
|
|
816
577
|
if (handler == null) {
|
|
817
578
|
return {
|
|
@@ -842,8 +603,8 @@ async function ___handleMatchmakingFunction(request: FunctionRequest): Promise<F
|
|
|
842
603
|
return answer;
|
|
843
604
|
}
|
|
844
605
|
|
|
845
|
-
async function
|
|
846
|
-
let handler = systemGenericServiceHandlers[
|
|
606
|
+
async function ___handleSystemGenericServiceFunction(name: string, request: FunctionRequestSystemVerifyGenericService): Promise<FunctionResponse> {
|
|
607
|
+
let handler = systemGenericServiceHandlers[name];
|
|
847
608
|
|
|
848
609
|
if (handler == null) {
|
|
849
610
|
return {
|
|
@@ -874,8 +635,37 @@ async function ___handleGenericServiceFunction(request: FunctionRequest): Promis
|
|
|
874
635
|
return answer;
|
|
875
636
|
}
|
|
876
637
|
|
|
877
|
-
async function
|
|
878
|
-
let handler =
|
|
638
|
+
async function ___handleSocketFunction(name: string, request: FunctionRequestSocket): Promise<FunctionResponse> {
|
|
639
|
+
let handler = socketHandlers[name];
|
|
640
|
+
|
|
641
|
+
if (handler == null) {
|
|
642
|
+
return {
|
|
643
|
+
status: ExecuteResponseStatus.FunctionNameNotFound,
|
|
644
|
+
result: null,
|
|
645
|
+
request: null,
|
|
646
|
+
errorMessage: null,
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
let answer: FunctionResponse = {
|
|
651
|
+
status: ExecuteResponseStatus.Ok,
|
|
652
|
+
errorMessage: null,
|
|
653
|
+
result: null,
|
|
654
|
+
request: null,
|
|
655
|
+
};
|
|
656
|
+
|
|
657
|
+
try {
|
|
658
|
+
await handler(request.request.userId, request.request.socketId, request.log);
|
|
659
|
+
} catch (err: any) {
|
|
660
|
+
answer.status = ExecuteResponseStatus.Exception;
|
|
661
|
+
answer.errorMessage = err.message;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
return answer;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
async function ___handleSystemAuthenticateFunction(name: string, request: FunctionRequestSystemAuthenticate): Promise<FunctionResponse> {
|
|
668
|
+
let handler = systemAuthenticateHandlers[name];
|
|
879
669
|
|
|
880
670
|
if (handler == null) {
|
|
881
671
|
return {
|
|
@@ -912,8 +702,8 @@ async function ___handleSystemAuthenticateFunction(request: FunctionRequest): Pr
|
|
|
912
702
|
return answer;
|
|
913
703
|
}
|
|
914
704
|
|
|
915
|
-
async function ___handleSystemFunction(request:
|
|
916
|
-
let handler = systemHandlers[
|
|
705
|
+
async function ___handleSystemFunction(name: string, request: FunctionRequestSystem): Promise<FunctionResponse> {
|
|
706
|
+
let handler = systemHandlers[name];
|
|
917
707
|
|
|
918
708
|
if (handler == null) {
|
|
919
709
|
return {
|
|
@@ -941,8 +731,8 @@ async function ___handleSystemFunction(request: FunctionRequest): Promise<Functi
|
|
|
941
731
|
return answer;
|
|
942
732
|
}
|
|
943
733
|
|
|
944
|
-
async function ___handleEventFunction(request:
|
|
945
|
-
let handler = eventHandlers[
|
|
734
|
+
async function ___handleEventFunction(name: string, request: FunctionRequestEvent): Promise<FunctionResponse> {
|
|
735
|
+
let handler = eventHandlers[name];
|
|
946
736
|
|
|
947
737
|
if (handler == null) {
|
|
948
738
|
return {
|
|
@@ -961,13 +751,12 @@ async function ___handleEventFunction(request: FunctionRequest): Promise<Functio
|
|
|
961
751
|
};
|
|
962
752
|
|
|
963
753
|
try {
|
|
964
|
-
await handler(request.request
|
|
754
|
+
await handler(request.request, request.operationEvent, request.log);
|
|
965
755
|
|
|
966
|
-
let operationEvent = request.
|
|
756
|
+
let operationEvent = request.operationEvent;
|
|
967
757
|
|
|
968
758
|
answer.result = {
|
|
969
|
-
|
|
970
|
-
debugMessage: null as any,
|
|
759
|
+
eventCode: operationEvent.getEventCode(),
|
|
971
760
|
parameters: operationEvent.getParameters()?.toData(),
|
|
972
761
|
};
|
|
973
762
|
|
|
@@ -980,8 +769,8 @@ async function ___handleEventFunction(request: FunctionRequest): Promise<Functio
|
|
|
980
769
|
return answer;
|
|
981
770
|
}
|
|
982
771
|
|
|
983
|
-
async function ___handlePreFunction(request:
|
|
984
|
-
let handler = preHandlers[
|
|
772
|
+
async function ___handlePreFunction(name: string, request: FunctionRequestPre): Promise<FunctionResponse> {
|
|
773
|
+
let handler = preHandlers[name];
|
|
985
774
|
|
|
986
775
|
if (handler == null) {
|
|
987
776
|
return {
|
|
@@ -1002,7 +791,7 @@ async function ___handlePreFunction(request: FunctionRequest): Promise<FunctionR
|
|
|
1002
791
|
try {
|
|
1003
792
|
let result = await handler(request.request, request.secretInfo, request.operationRequest, request.log);
|
|
1004
793
|
|
|
1005
|
-
if (result
|
|
794
|
+
if (result)
|
|
1006
795
|
answer.result = {
|
|
1007
796
|
returnCode: result.getReturnCode(),
|
|
1008
797
|
debugMessage: result.getDebugMessage(),
|
|
@@ -1018,8 +807,8 @@ async function ___handlePreFunction(request: FunctionRequest): Promise<FunctionR
|
|
|
1018
807
|
return answer;
|
|
1019
808
|
}
|
|
1020
809
|
|
|
1021
|
-
async function ___handlePostFunction(request:
|
|
1022
|
-
let handler = postHandlers[
|
|
810
|
+
async function ___handlePostFunction(name: string, request: FunctionRequestPost): Promise<FunctionResponse> {
|
|
811
|
+
let handler = postHandlers[name];
|
|
1023
812
|
|
|
1024
813
|
if (handler == null) {
|
|
1025
814
|
return {
|
|
@@ -1077,6 +866,7 @@ const pushNotification = new CloudScriptPushNotification();
|
|
|
1077
866
|
database.init(dbConnection.url, dbConnection.dbName, dbConnection.logUrl, dbConnection.logDbName, dbConnection.options);
|
|
1078
867
|
}
|
|
1079
868
|
|
|
869
|
+
// release after init success
|
|
1080
870
|
process.env.dbConnection = "";
|
|
1081
871
|
process.env.gnServerSettingsOptions = "";
|
|
1082
872
|
|
|
@@ -1094,4 +884,6 @@ const systemAuthenticateHandlers: Record<string, (request: { userId: string, ipA
|
|
|
1094
884
|
|
|
1095
885
|
const systemGenericServiceHandlers: Record<string, (serviceName: string, serviceData: { [k: string]: any; }, log: (log: any) => void) => Promise<{ success: boolean, serviceId: string, someDatas?: any, errorMessage?: string }>> = {};
|
|
1096
886
|
|
|
1097
|
-
|
|
887
|
+
const socketHandlers: Record<string, (userId: string, socketId: string, log: (log: any) => void) => Promise<void>> = {};
|
|
888
|
+
|
|
889
|
+
//$replaceScript
|