@xmobitea/gn-server 2.4.1 → 2.4.3
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-startup/settings/SocketAppSettings.d.ts +3 -0
- package/dist/index.js +93 -39
- package/gn.sh +1 -0
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import { IBuilder } from "./../../GN-library/xbuilder/lib/IBuilder";
|
|
|
2
2
|
type MethodType = "GET" | "HEAD" | "PUT" | "PATCH" | "POST" | "DELETE" | "UPDATE";
|
|
3
3
|
declare abstract class BuilderBase {
|
|
4
4
|
protected enable: boolean;
|
|
5
|
+
protected useEmitter: boolean;
|
|
5
6
|
protected origin: string;
|
|
6
7
|
protected methods: MethodType[];
|
|
7
8
|
protected allowedHeaders: string[];
|
|
@@ -12,6 +13,7 @@ declare abstract class BuilderBase {
|
|
|
12
13
|
protected pingInterval: number;
|
|
13
14
|
protected pingTimeout: number;
|
|
14
15
|
getEnable(): boolean;
|
|
16
|
+
getUseEmitter(): boolean;
|
|
15
17
|
getOrigin(): string;
|
|
16
18
|
getMethods(): MethodType[];
|
|
17
19
|
getAllowedHeaders(): string[];
|
|
@@ -34,6 +36,7 @@ declare class Builder extends BuilderBase implements IBuilder<SocketAppSettings>
|
|
|
34
36
|
setPingInterval(pingInterval: number): Builder;
|
|
35
37
|
setPingTimeout(pingTimeout: number): Builder;
|
|
36
38
|
setEnable(enable: boolean): Builder;
|
|
39
|
+
setUseEmitter(useEmitter: boolean): Builder;
|
|
37
40
|
setEnableSendAndReceiveDebug(enableSendAndReceiveDebug: boolean): Builder;
|
|
38
41
|
setEnablePostViaMsgPack(enablePostViaMsgPack: boolean): Builder;
|
|
39
42
|
setEnablePostViaJson(enablePostViaJson: boolean): Builder;
|
package/dist/index.js
CHANGED
|
@@ -15528,22 +15528,23 @@ class GetBackupStatisticsLeaderboardVersionRequestHandler extends RequestHandler
|
|
|
15528
15528
|
}
|
|
15529
15529
|
operationResponse = new OperationResponse_1.OperationResponse(operationRequest.getOperationCode(), operationRequest.getRequestId(), operationRequest.isEncrypted());
|
|
15530
15530
|
operationResponse.setReturnCode(ReturnCode_1.ReturnCode.Ok);
|
|
15531
|
+
let type = request.type;
|
|
15531
15532
|
let backupStatisticsLeaderboardCollection;
|
|
15532
|
-
if (
|
|
15533
|
+
if (type == OwnerType_1.OwnerType.MasterPlayer) {
|
|
15533
15534
|
backupStatisticsLeaderboardCollection = this.gnServer.getDatabase().systemCollection("MasterPlayer.StatisticsBackup");
|
|
15534
15535
|
}
|
|
15535
15536
|
else {
|
|
15536
15537
|
let gameId = request.gameId;
|
|
15537
|
-
if (
|
|
15538
|
+
if (type == OwnerType_1.OwnerType.GamePlayer) {
|
|
15538
15539
|
backupStatisticsLeaderboardCollection = this.gnServer.getDatabase().systemGameCollection("GamePlayer.StatisticsBackup", gameId);
|
|
15539
15540
|
}
|
|
15540
|
-
else if (
|
|
15541
|
+
else if (type == OwnerType_1.OwnerType.CharacterPlayer) {
|
|
15541
15542
|
backupStatisticsLeaderboardCollection = this.gnServer.getDatabase().systemGameCollection("CharacterPlayer.StatisticsBackup", gameId);
|
|
15542
15543
|
}
|
|
15543
|
-
else if (
|
|
15544
|
+
else if (type == OwnerType_1.OwnerType.Inventory) {
|
|
15544
15545
|
backupStatisticsLeaderboardCollection = this.gnServer.getDatabase().systemGameCollection("Inventory.StatisticsBackup", gameId);
|
|
15545
15546
|
}
|
|
15546
|
-
else if (
|
|
15547
|
+
else if (type == OwnerType_1.OwnerType.Group) {
|
|
15547
15548
|
backupStatisticsLeaderboardCollection = this.gnServer.getDatabase().systemGameCollection("Group.StatisticsBackup", gameId);
|
|
15548
15549
|
}
|
|
15549
15550
|
else {
|
|
@@ -15551,9 +15552,8 @@ class GetBackupStatisticsLeaderboardVersionRequestHandler extends RequestHandler
|
|
|
15551
15552
|
return operationResponse;
|
|
15552
15553
|
}
|
|
15553
15554
|
}
|
|
15554
|
-
let type = request.type;
|
|
15555
15555
|
let key = request.key;
|
|
15556
|
-
let results = backupStatisticsLeaderboardCollection.find({
|
|
15556
|
+
let results = backupStatisticsLeaderboardCollection.find({ key: key }, {
|
|
15557
15557
|
projection: {
|
|
15558
15558
|
version: true,
|
|
15559
15559
|
log: true,
|
|
@@ -87765,7 +87765,9 @@ class SocketApp {
|
|
|
87765
87765
|
}
|
|
87766
87766
|
});
|
|
87767
87767
|
this.socketAppHandler = new SocketAppHandler_1.SocketAppHandler();
|
|
87768
|
-
this.
|
|
87768
|
+
if (this.appSettings.getUseEmitter()) {
|
|
87769
|
+
this.socketAppHandler.setEmitter(this.emitter);
|
|
87770
|
+
}
|
|
87769
87771
|
this.socketAppHandler.setServer(this.io);
|
|
87770
87772
|
this.socketAppHandler.setApiMiddleware(this.apiMiddleware);
|
|
87771
87773
|
this.socketAppHandler.setAntiDdosMiddleware(this.antiDdosMiddleware);
|
|
@@ -87779,8 +87781,9 @@ class SocketApp {
|
|
|
87779
87781
|
}
|
|
87780
87782
|
setEmitter(adapterEventCollection) {
|
|
87781
87783
|
this.emitter = new mongo_emitter_1.Emitter(adapterEventCollection);
|
|
87782
|
-
if (this.socketAppHandler != null)
|
|
87784
|
+
if (this.appSettings.getUseEmitter() && this.socketAppHandler != null) {
|
|
87783
87785
|
this.socketAppHandler.setEmitter(this.emitter);
|
|
87786
|
+
}
|
|
87784
87787
|
this.io.adapter((0, mongo_adapter_1.createAdapter)(adapterEventCollection, {}));
|
|
87785
87788
|
}
|
|
87786
87789
|
constructor() { }
|
|
@@ -89537,29 +89540,44 @@ class SocketAppHandler {
|
|
|
89537
89540
|
let socketData = OperationHelper_1.OperationHelper.toResponseSocketData(operationResponse);
|
|
89538
89541
|
if (this.enableSendAndReceiveDebug)
|
|
89539
89542
|
xDebug_1.Debug.log("[SOCKET SEND] %O", JSON.stringify(socketData));
|
|
89540
|
-
if (operationResponse.isEncrypted())
|
|
89541
|
-
|
|
89542
|
-
|
|
89543
|
+
if (operationResponse.isEncrypted()) {
|
|
89544
|
+
let socketDataMsgPack = (0, msgpack_1.encode)(socketData);
|
|
89545
|
+
socket.emit(Commands_1.Commands.ResponseCmd_MsgPack, socketDataMsgPack);
|
|
89546
|
+
}
|
|
89547
|
+
else {
|
|
89543
89548
|
socket.emit(Commands_1.Commands.ResponseCmd_Json, socketData);
|
|
89549
|
+
}
|
|
89544
89550
|
}
|
|
89545
89551
|
sendEventForSocket(socket, operationEvent) {
|
|
89546
89552
|
let socketData = OperationHelper_1.OperationHelper.toEventSocketData(operationEvent);
|
|
89547
89553
|
if (this.enableSendAndReceiveDebug)
|
|
89548
89554
|
xDebug_1.Debug.log("[EVENT SEND] %O", JSON.stringify(socketData));
|
|
89549
|
-
if (operationEvent.isEncrypted())
|
|
89550
|
-
|
|
89551
|
-
|
|
89555
|
+
if (operationEvent.isEncrypted()) {
|
|
89556
|
+
let socketDataMsgPack = (0, msgpack_1.encode)(socketData);
|
|
89557
|
+
socket.emit(Commands_1.Commands.EventCmd_MsgPack, socketDataMsgPack);
|
|
89558
|
+
}
|
|
89559
|
+
else {
|
|
89552
89560
|
socket.emit(Commands_1.Commands.EventCmd_Json, socketData);
|
|
89561
|
+
}
|
|
89553
89562
|
}
|
|
89554
89563
|
sendEventTo(userId, operationEvent) {
|
|
89555
89564
|
return __awaiter(this, void 0, void 0, function* () {
|
|
89556
89565
|
let socketData = OperationHelper_1.OperationHelper.toEventSocketData(operationEvent);
|
|
89557
89566
|
if (this.enableSendAndReceiveDebug)
|
|
89558
89567
|
xDebug_1.Debug.log("[EVENT SEND EVENT TO] " + userId + " %O", JSON.stringify(socketData));
|
|
89559
|
-
if (operationEvent.isEncrypted())
|
|
89560
|
-
|
|
89561
|
-
|
|
89562
|
-
|
|
89568
|
+
if (operationEvent.isEncrypted()) {
|
|
89569
|
+
let socketDataMsgPack = (0, msgpack_1.encode)(socketData);
|
|
89570
|
+
if (this.emitter != null)
|
|
89571
|
+
this.emitter.to(userId).emit(Commands_1.Commands.EventCmd_MsgPack, socketDataMsgPack);
|
|
89572
|
+
else
|
|
89573
|
+
this.server.to(userId).emit(Commands_1.Commands.EventCmd_MsgPack, (0, msgpack_1.encode)(socketData));
|
|
89574
|
+
}
|
|
89575
|
+
else {
|
|
89576
|
+
if (this.emitter != null)
|
|
89577
|
+
this.emitter.to(userId).emit(Commands_1.Commands.EventCmd_Json, socketData);
|
|
89578
|
+
else
|
|
89579
|
+
this.server.to(userId).emit(Commands_1.Commands.EventCmd_Json, socketData);
|
|
89580
|
+
}
|
|
89563
89581
|
});
|
|
89564
89582
|
}
|
|
89565
89583
|
sendEventToRoom(roomId, operationEvent) {
|
|
@@ -89567,10 +89585,19 @@ class SocketAppHandler {
|
|
|
89567
89585
|
let socketData = OperationHelper_1.OperationHelper.toEventSocketData(operationEvent);
|
|
89568
89586
|
if (this.enableSendAndReceiveDebug)
|
|
89569
89587
|
xDebug_1.Debug.log("[EVENT SEND EVENT TO ROOM] " + roomId + " %O", JSON.stringify(socketData));
|
|
89570
|
-
if (operationEvent.isEncrypted())
|
|
89571
|
-
|
|
89572
|
-
|
|
89573
|
-
|
|
89588
|
+
if (operationEvent.isEncrypted()) {
|
|
89589
|
+
let socketDataMsgPack = (0, msgpack_1.encode)(socketData);
|
|
89590
|
+
if (this.emitter != null)
|
|
89591
|
+
this.emitter.to(roomId).emit(Commands_1.Commands.EventCmd_MsgPack, socketDataMsgPack);
|
|
89592
|
+
else
|
|
89593
|
+
this.server.to(roomId).emit(Commands_1.Commands.EventCmd_MsgPack, (0, msgpack_1.encode)(socketData));
|
|
89594
|
+
}
|
|
89595
|
+
else {
|
|
89596
|
+
if (this.emitter != null)
|
|
89597
|
+
this.emitter.to(roomId).emit(Commands_1.Commands.EventCmd_Json, socketData);
|
|
89598
|
+
else
|
|
89599
|
+
this.server.to(roomId).emit(Commands_1.Commands.EventCmd_Json, socketData);
|
|
89600
|
+
}
|
|
89574
89601
|
});
|
|
89575
89602
|
}
|
|
89576
89603
|
sendEventToMoreUser(userIds, operationEvent) {
|
|
@@ -89580,16 +89607,16 @@ class SocketAppHandler {
|
|
|
89580
89607
|
xDebug_1.Debug.log("[EVENT SEND EVENT TO MORE USER] %O", JSON.stringify(socketData));
|
|
89581
89608
|
if (operationEvent.isEncrypted()) {
|
|
89582
89609
|
let socketDataMsgPack = (0, msgpack_1.encode)(socketData);
|
|
89583
|
-
|
|
89584
|
-
|
|
89585
|
-
|
|
89586
|
-
|
|
89610
|
+
if (this.emitter != null)
|
|
89611
|
+
this.emitter.to(userIds).emit(Commands_1.Commands.EventCmd_MsgPack, socketDataMsgPack);
|
|
89612
|
+
else
|
|
89613
|
+
this.server.to(userIds).emit(Commands_1.Commands.EventCmd_MsgPack, socketDataMsgPack);
|
|
89587
89614
|
}
|
|
89588
89615
|
else {
|
|
89589
|
-
|
|
89590
|
-
|
|
89591
|
-
|
|
89592
|
-
|
|
89616
|
+
if (this.emitter != null)
|
|
89617
|
+
this.emitter.to(userIds).emit(Commands_1.Commands.EventCmd_Json, socketData);
|
|
89618
|
+
else
|
|
89619
|
+
this.server.to(userIds).emit(Commands_1.Commands.EventCmd_Json, socketData);
|
|
89593
89620
|
}
|
|
89594
89621
|
});
|
|
89595
89622
|
}
|
|
@@ -89598,10 +89625,19 @@ class SocketAppHandler {
|
|
|
89598
89625
|
let socketData = OperationHelper_1.OperationHelper.toEventSocketData(operationEvent);
|
|
89599
89626
|
if (this.enableSendAndReceiveDebug)
|
|
89600
89627
|
xDebug_1.Debug.log("[EVENT SEND EVENT TO ALL PLAYER] %O", JSON.stringify(socketData));
|
|
89601
|
-
if (operationEvent.isEncrypted())
|
|
89602
|
-
|
|
89603
|
-
|
|
89604
|
-
|
|
89628
|
+
if (operationEvent.isEncrypted()) {
|
|
89629
|
+
let socketDataMsgPack = (0, msgpack_1.encode)(socketData);
|
|
89630
|
+
if (this.emitter != null)
|
|
89631
|
+
this.emitter.emit(Commands_1.Commands.EventCmd_MsgPack, socketDataMsgPack);
|
|
89632
|
+
else
|
|
89633
|
+
this.server.emit(Commands_1.Commands.EventCmd_MsgPack, socketDataMsgPack);
|
|
89634
|
+
}
|
|
89635
|
+
else {
|
|
89636
|
+
if (this.emitter != null)
|
|
89637
|
+
this.emitter.emit(Commands_1.Commands.EventCmd_Json, socketData);
|
|
89638
|
+
else
|
|
89639
|
+
this.server.emit(Commands_1.Commands.EventCmd_Json, socketData);
|
|
89640
|
+
}
|
|
89605
89641
|
});
|
|
89606
89642
|
}
|
|
89607
89643
|
sendEventToNamespace(namespace, operationEvent) {
|
|
@@ -89609,10 +89645,19 @@ class SocketAppHandler {
|
|
|
89609
89645
|
let socketData = OperationHelper_1.OperationHelper.toEventSocketData(operationEvent);
|
|
89610
89646
|
if (this.enableSendAndReceiveDebug)
|
|
89611
89647
|
xDebug_1.Debug.log("[EVENT SEND EVENT TO NAME SPACE] %O", JSON.stringify(socketData));
|
|
89612
|
-
if (operationEvent.isEncrypted())
|
|
89613
|
-
|
|
89614
|
-
|
|
89615
|
-
|
|
89648
|
+
if (operationEvent.isEncrypted()) {
|
|
89649
|
+
let socketDataMsgPack = (0, msgpack_1.encode)(socketData);
|
|
89650
|
+
if (this.emitter != null)
|
|
89651
|
+
this.emitter.of("/" + namespace).emit(Commands_1.Commands.EventCmd_MsgPack, socketDataMsgPack);
|
|
89652
|
+
else
|
|
89653
|
+
this.server.of("/" + namespace).emit(Commands_1.Commands.EventCmd_MsgPack, socketDataMsgPack);
|
|
89654
|
+
}
|
|
89655
|
+
else {
|
|
89656
|
+
if (this.emitter != null)
|
|
89657
|
+
this.emitter.of("/" + namespace).emit(Commands_1.Commands.EventCmd_Json, socketData);
|
|
89658
|
+
else
|
|
89659
|
+
this.server.of("/" + namespace).emit(Commands_1.Commands.EventCmd_Json, socketData);
|
|
89660
|
+
}
|
|
89616
89661
|
});
|
|
89617
89662
|
}
|
|
89618
89663
|
getSocketViaSocketId(socketId) {
|
|
@@ -90300,6 +90345,9 @@ class BuilderBase {
|
|
|
90300
90345
|
getEnable() {
|
|
90301
90346
|
return this.enable;
|
|
90302
90347
|
}
|
|
90348
|
+
getUseEmitter() {
|
|
90349
|
+
return this.useEmitter;
|
|
90350
|
+
}
|
|
90303
90351
|
getOrigin() {
|
|
90304
90352
|
return this.origin;
|
|
90305
90353
|
}
|
|
@@ -90375,6 +90423,10 @@ class Builder extends BuilderBase {
|
|
|
90375
90423
|
this.enable = enable;
|
|
90376
90424
|
return this;
|
|
90377
90425
|
}
|
|
90426
|
+
setUseEmitter(useEmitter) {
|
|
90427
|
+
this.useEmitter = useEmitter;
|
|
90428
|
+
return this;
|
|
90429
|
+
}
|
|
90378
90430
|
setEnableSendAndReceiveDebug(enableSendAndReceiveDebug) {
|
|
90379
90431
|
this.enableSendAndReceiveDebug = enableSendAndReceiveDebug;
|
|
90380
90432
|
return this;
|
|
@@ -90390,6 +90442,7 @@ class Builder extends BuilderBase {
|
|
|
90390
90442
|
constructor() {
|
|
90391
90443
|
super();
|
|
90392
90444
|
this.enable = false;
|
|
90445
|
+
this.useEmitter = false;
|
|
90393
90446
|
this.origin = "";
|
|
90394
90447
|
this.methods = [];
|
|
90395
90448
|
this.allowedHeaders = [];
|
|
@@ -90412,6 +90465,7 @@ class SocketAppSettings extends BuilderBase {
|
|
|
90412
90465
|
this.origin = builder.getOrigin();
|
|
90413
90466
|
this.methods = builder.getMethods();
|
|
90414
90467
|
this.enable = builder.getEnable();
|
|
90468
|
+
this.useEmitter = builder.getUseEmitter();
|
|
90415
90469
|
this.allowedHeaders = builder.getAllowedHeaders();
|
|
90416
90470
|
this.credentials = builder.getCredentials();
|
|
90417
90471
|
this.enableSendAndReceiveDebug = builder.getEnableSendAndReceiveDebug();
|
package/gn.sh
CHANGED