@xmobitea/gn-server 2.4.2 → 2.4.4

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.
@@ -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
@@ -86064,6 +86064,7 @@ class DefaultApplicationStartup {
86064
86064
  .build();
86065
86065
  let socketAppSettings = SocketAppSettings_1.SocketAppSettings.Builder()
86066
86066
  .setEnable(true)
86067
+ .setUseEmitter(false)
86067
86068
  .setOrigins("*")
86068
86069
  .addMethods([])
86069
86070
  .setCredentials(true)
@@ -87562,7 +87563,7 @@ class ServerApplicationStartup extends DefaultApplicationStartup_1.DefaultApplic
87562
87563
  this.gnConfig = gnConfig;
87563
87564
  }
87564
87565
  run(onRunSuccess) {
87565
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22;
87566
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23;
87566
87567
  let gnApplicationSettings = this.gnConfig["applicationSettings"];
87567
87568
  if (gnApplicationSettings == null)
87568
87569
  gnApplicationSettings = {
@@ -87618,15 +87619,16 @@ class ServerApplicationStartup extends DefaultApplicationStartup_1.DefaultApplic
87618
87619
  };
87619
87620
  let socketAppSettings = SocketAppSettings_1.SocketAppSettings.Builder()
87620
87621
  .setEnable((_q = gnSocketAppSettings["enable"]) !== null && _q !== void 0 ? _q : true)
87621
- .setOrigins((_r = gnSocketAppSettings["allowOrigin"]) !== null && _r !== void 0 ? _r : "*")
87622
- .addMethods((_s = gnSocketAppSettings["allowMethods"]) !== null && _s !== void 0 ? _s : ["GET"])
87623
- .setCredentials((_t = gnSocketAppSettings["credentials"]) !== null && _t !== void 0 ? _t : true)
87624
- .setEnablePostViaMsgPack((_u = gnSocketAppSettings["enablePostViaMsgPack"]) !== null && _u !== void 0 ? _u : true)
87625
- .setEnablePostViaJson((_v = gnSocketAppSettings["enablePostViaJson"]) !== null && _v !== void 0 ? _v : true)
87626
- .addAllowedHeaders((_w = gnSocketAppSettings["allowHeaders"]) !== null && _w !== void 0 ? _w : [])
87627
- .setPingInterval((_x = gnSocketAppSettings["pingInterval"]) !== null && _x !== void 0 ? _x : 50000)
87628
- .setPingTimeout((_y = gnSocketAppSettings["pingTimeout"]) !== null && _y !== void 0 ? _y : 5000)
87629
- .setEnableSendAndReceiveDebug((_z = gnSocketAppSettings["enableSendAndReceiveDebug"]) !== null && _z !== void 0 ? _z : true)
87622
+ .setUseEmitter((_r = gnSocketAppSettings["useEmitter"]) !== null && _r !== void 0 ? _r : false)
87623
+ .setOrigins((_s = gnSocketAppSettings["allowOrigin"]) !== null && _s !== void 0 ? _s : "*")
87624
+ .addMethods((_t = gnSocketAppSettings["allowMethods"]) !== null && _t !== void 0 ? _t : ["GET"])
87625
+ .setCredentials((_u = gnSocketAppSettings["credentials"]) !== null && _u !== void 0 ? _u : true)
87626
+ .setEnablePostViaMsgPack((_v = gnSocketAppSettings["enablePostViaMsgPack"]) !== null && _v !== void 0 ? _v : true)
87627
+ .setEnablePostViaJson((_w = gnSocketAppSettings["enablePostViaJson"]) !== null && _w !== void 0 ? _w : true)
87628
+ .addAllowedHeaders((_x = gnSocketAppSettings["allowHeaders"]) !== null && _x !== void 0 ? _x : [])
87629
+ .setPingInterval((_y = gnSocketAppSettings["pingInterval"]) !== null && _y !== void 0 ? _y : 50000)
87630
+ .setPingTimeout((_z = gnSocketAppSettings["pingTimeout"]) !== null && _z !== void 0 ? _z : 5000)
87631
+ .setEnableSendAndReceiveDebug((_0 = gnSocketAppSettings["enableSendAndReceiveDebug"]) !== null && _0 !== void 0 ? _0 : true)
87630
87632
  .build();
87631
87633
  let gnOtherSettings = this.gnConfig["otherSettings"];
87632
87634
  if (gnOtherSettings == null)
@@ -87634,8 +87636,8 @@ class ServerApplicationStartup extends DefaultApplicationStartup_1.DefaultApplic
87634
87636
  "headerIP": "x-ip",
87635
87637
  };
87636
87638
  let otherSettings = OtherSettings_1.OtherSettings.Builder()
87637
- .setHeaderIP((_0 = gnOtherSettings["headerIP"]) !== null && _0 !== void 0 ? _0 : "x-ip")
87638
- .setIdTypeCase((_1 = gnOtherSettings["idTypeCase"]) !== null && _1 !== void 0 ? _1 : 0)
87639
+ .setHeaderIP((_1 = gnOtherSettings["headerIP"]) !== null && _1 !== void 0 ? _1 : "x-ip")
87640
+ .setIdTypeCase((_2 = gnOtherSettings["idTypeCase"]) !== null && _2 !== void 0 ? _2 : 0)
87639
87641
  .setIPApiUrl(gnOtherSettings["ipApiUrl"])
87640
87642
  .build();
87641
87643
  let gnDatabaseSettings = this.gnConfig["databaseSettings"];
@@ -87646,9 +87648,9 @@ class ServerApplicationStartup extends DefaultApplicationStartup_1.DefaultApplic
87646
87648
  "options": {},
87647
87649
  };
87648
87650
  let databaseSettings = DatabaseSettings_1.DatabaseSettings.Builder()
87649
- .setConnectionString((_2 = gnDatabaseSettings["connectionString"]) !== null && _2 !== void 0 ? _2 : "mongodb://127.0.0.1:27017/")
87650
- .setDatabaseName((_3 = gnDatabaseSettings["databaseName"]) !== null && _3 !== void 0 ? _3 : "XmobiTea")
87651
- .setOptions((_4 = gnDatabaseSettings["options"]) !== null && _4 !== void 0 ? _4 : {})
87651
+ .setConnectionString((_3 = gnDatabaseSettings["connectionString"]) !== null && _3 !== void 0 ? _3 : "mongodb://127.0.0.1:27017/")
87652
+ .setDatabaseName((_4 = gnDatabaseSettings["databaseName"]) !== null && _4 !== void 0 ? _4 : "XmobiTea")
87653
+ .setOptions((_5 = gnDatabaseSettings["options"]) !== null && _5 !== void 0 ? _5 : {})
87652
87654
  .build();
87653
87655
  let gnLogSettings = this.gnConfig["logSettings"];
87654
87656
  if (gnLogSettings == null)
@@ -87658,9 +87660,9 @@ class ServerApplicationStartup extends DefaultApplicationStartup_1.DefaultApplic
87658
87660
  "logPath": "./log/debug/Server.log",
87659
87661
  };
87660
87662
  let logSettings = LogSettings_1.LogSettings.Builder()
87661
- .setLogToFileEnable((_5 = gnLogSettings["logToFileEnable"]) !== null && _5 !== void 0 ? _5 : true)
87662
- .setLogToConsoleEnable((_6 = gnLogSettings["logToConsoleEnable"]) !== null && _6 !== void 0 ? _6 : true)
87663
- .setLogPath((_7 = gnLogSettings["logPath"]) !== null && _7 !== void 0 ? _7 : "./log/debug/Server.log")
87663
+ .setLogToFileEnable((_6 = gnLogSettings["logToFileEnable"]) !== null && _6 !== void 0 ? _6 : true)
87664
+ .setLogToConsoleEnable((_7 = gnLogSettings["logToConsoleEnable"]) !== null && _7 !== void 0 ? _7 : true)
87665
+ .setLogPath((_8 = gnLogSettings["logPath"]) !== null && _8 !== void 0 ? _8 : "./log/debug/Server.log")
87664
87666
  .build();
87665
87667
  let gnUploadFileSettings = this.gnConfig["uploadFileSettings"];
87666
87668
  if (gnUploadFileSettings == null)
@@ -87671,10 +87673,10 @@ class ServerApplicationStartup extends DefaultApplicationStartup_1.DefaultApplic
87671
87673
  "mimeTypeAccepts": ["image/png"],
87672
87674
  };
87673
87675
  let uploadFileSettings = UploadFileSettings_1.UploadFileSettings.Builder()
87674
- .setEnable((_8 = gnUploadFileSettings["enable"]) !== null && _8 !== void 0 ? _8 : true)
87675
- .setUploadPath((_9 = gnUploadFileSettings["uploadPath"]) !== null && _9 !== void 0 ? _9 : "./file-upload")
87676
- .setMaxSizeUpload((_10 = gnUploadFileSettings["maxSizeUpload"]) !== null && _10 !== void 0 ? _10 : 52428800)
87677
- .setMimeTypeAccepts((_11 = gnUploadFileSettings["mimeTypeAccepts"]) !== null && _11 !== void 0 ? _11 : ["image/png"])
87676
+ .setEnable((_9 = gnUploadFileSettings["enable"]) !== null && _9 !== void 0 ? _9 : true)
87677
+ .setUploadPath((_10 = gnUploadFileSettings["uploadPath"]) !== null && _10 !== void 0 ? _10 : "./file-upload")
87678
+ .setMaxSizeUpload((_11 = gnUploadFileSettings["maxSizeUpload"]) !== null && _11 !== void 0 ? _11 : 52428800)
87679
+ .setMimeTypeAccepts((_12 = gnUploadFileSettings["mimeTypeAccepts"]) !== null && _12 !== void 0 ? _12 : ["image/png"])
87678
87680
  .build();
87679
87681
  let gnDdosSettings = this.gnConfig["ddosSettings"];
87680
87682
  if (gnDdosSettings == null)
@@ -87691,17 +87693,17 @@ class ServerApplicationStartup extends DefaultApplicationStartup_1.DefaultApplic
87691
87693
  "maxDownloadPendingRequest": 200,
87692
87694
  };
87693
87695
  let ddosSettings = DDosSettings_1.DdosSettings.Builder()
87694
- .setSocketMaxRequestPerSecondPerIp((_12 = gnDdosSettings["socketMaxRequestPerSecondPerIp"]) !== null && _12 !== void 0 ? _12 : 50)
87695
- .setSocketMaxRequestPerSecondPerPeer((_13 = gnDdosSettings["socketMaxRequestPerSecondPerPeer"]) !== null && _13 !== void 0 ? _13 : 20)
87696
- .setSocketMaxPendingRequest((_14 = gnDdosSettings["socketMaxPendingRequest"]) !== null && _14 !== void 0 ? _14 : 1000)
87697
- .setSocketMaxRequestSize((_15 = gnDdosSettings["socketMaxRequestSize"]) !== null && _15 !== void 0 ? _15 : 1024)
87698
- .setHttpMaxRequestPerSecondPerIp((_16 = gnDdosSettings["httpMaxRequestPerSecondPerIp"]) !== null && _16 !== void 0 ? _16 : 50)
87699
- .setHttpMaxRequestPerSecondPerPeer((_17 = gnDdosSettings["httpMaxRequestPerSecondPerPeer"]) !== null && _17 !== void 0 ? _17 : 20)
87700
- .setHttpMaxPendingRequest((_18 = gnDdosSettings["httpMaxPendingRequest"]) !== null && _18 !== void 0 ? _18 : 1000)
87701
- .setHttpMaxRequestSize((_19 = gnDdosSettings["httpMaxRequestSize"]) !== null && _19 !== void 0 ? _19 : 1024)
87702
- .setMaxUploadPendingRequest((_20 = gnDdosSettings["maxUploadPendingRequest"]) !== null && _20 !== void 0 ? _20 : 200)
87703
- .setMaxDownloadPendingRequest((_21 = gnDdosSettings["maxDownloadPendingRequest"]) !== null && _21 !== void 0 ? _21 : 200)
87704
- .setIPWhiteList((_22 = gnDdosSettings["ipWhiteList"]) !== null && _22 !== void 0 ? _22 : [])
87696
+ .setSocketMaxRequestPerSecondPerIp((_13 = gnDdosSettings["socketMaxRequestPerSecondPerIp"]) !== null && _13 !== void 0 ? _13 : 50)
87697
+ .setSocketMaxRequestPerSecondPerPeer((_14 = gnDdosSettings["socketMaxRequestPerSecondPerPeer"]) !== null && _14 !== void 0 ? _14 : 20)
87698
+ .setSocketMaxPendingRequest((_15 = gnDdosSettings["socketMaxPendingRequest"]) !== null && _15 !== void 0 ? _15 : 1000)
87699
+ .setSocketMaxRequestSize((_16 = gnDdosSettings["socketMaxRequestSize"]) !== null && _16 !== void 0 ? _16 : 1024)
87700
+ .setHttpMaxRequestPerSecondPerIp((_17 = gnDdosSettings["httpMaxRequestPerSecondPerIp"]) !== null && _17 !== void 0 ? _17 : 50)
87701
+ .setHttpMaxRequestPerSecondPerPeer((_18 = gnDdosSettings["httpMaxRequestPerSecondPerPeer"]) !== null && _18 !== void 0 ? _18 : 20)
87702
+ .setHttpMaxPendingRequest((_19 = gnDdosSettings["httpMaxPendingRequest"]) !== null && _19 !== void 0 ? _19 : 1000)
87703
+ .setHttpMaxRequestSize((_20 = gnDdosSettings["httpMaxRequestSize"]) !== null && _20 !== void 0 ? _20 : 1024)
87704
+ .setMaxUploadPendingRequest((_21 = gnDdosSettings["maxUploadPendingRequest"]) !== null && _21 !== void 0 ? _21 : 200)
87705
+ .setMaxDownloadPendingRequest((_22 = gnDdosSettings["maxDownloadPendingRequest"]) !== null && _22 !== void 0 ? _22 : 200)
87706
+ .setIPWhiteList((_23 = gnDdosSettings["ipWhiteList"]) !== null && _23 !== void 0 ? _23 : [])
87705
87707
  .build();
87706
87708
  this.serverApplication = this.newServerApplication(applicationSettings, httpAppSettings, socketAppSettings, otherSettings, databaseSettings, logSettings, uploadFileSettings, ddosSettings);
87707
87709
  this.serverApplication.run(() => {
@@ -87765,7 +87767,9 @@ class SocketApp {
87765
87767
  }
87766
87768
  });
87767
87769
  this.socketAppHandler = new SocketAppHandler_1.SocketAppHandler();
87768
- this.socketAppHandler.setEmitter(this.emitter);
87770
+ if (this.appSettings.getUseEmitter()) {
87771
+ this.socketAppHandler.setEmitter(this.emitter);
87772
+ }
87769
87773
  this.socketAppHandler.setServer(this.io);
87770
87774
  this.socketAppHandler.setApiMiddleware(this.apiMiddleware);
87771
87775
  this.socketAppHandler.setAntiDdosMiddleware(this.antiDdosMiddleware);
@@ -87779,8 +87783,9 @@ class SocketApp {
87779
87783
  }
87780
87784
  setEmitter(adapterEventCollection) {
87781
87785
  this.emitter = new mongo_emitter_1.Emitter(adapterEventCollection);
87782
- if (this.socketAppHandler != null)
87786
+ if (this.appSettings.getUseEmitter() && this.socketAppHandler != null) {
87783
87787
  this.socketAppHandler.setEmitter(this.emitter);
87788
+ }
87784
87789
  this.io.adapter((0, mongo_adapter_1.createAdapter)(adapterEventCollection, {}));
87785
87790
  }
87786
87791
  constructor() { }
@@ -89537,29 +89542,44 @@ class SocketAppHandler {
89537
89542
  let socketData = OperationHelper_1.OperationHelper.toResponseSocketData(operationResponse);
89538
89543
  if (this.enableSendAndReceiveDebug)
89539
89544
  xDebug_1.Debug.log("[SOCKET SEND] %O", JSON.stringify(socketData));
89540
- if (operationResponse.isEncrypted())
89541
- socket.emit(Commands_1.Commands.ResponseCmd_MsgPack, (0, msgpack_1.encode)(socketData));
89542
- else
89545
+ if (operationResponse.isEncrypted()) {
89546
+ let socketDataMsgPack = (0, msgpack_1.encode)(socketData);
89547
+ socket.emit(Commands_1.Commands.ResponseCmd_MsgPack, socketDataMsgPack);
89548
+ }
89549
+ else {
89543
89550
  socket.emit(Commands_1.Commands.ResponseCmd_Json, socketData);
89551
+ }
89544
89552
  }
89545
89553
  sendEventForSocket(socket, operationEvent) {
89546
89554
  let socketData = OperationHelper_1.OperationHelper.toEventSocketData(operationEvent);
89547
89555
  if (this.enableSendAndReceiveDebug)
89548
89556
  xDebug_1.Debug.log("[EVENT SEND] %O", JSON.stringify(socketData));
89549
- if (operationEvent.isEncrypted())
89550
- socket.emit(Commands_1.Commands.EventCmd_MsgPack, (0, msgpack_1.encode)(socketData));
89551
- else
89557
+ if (operationEvent.isEncrypted()) {
89558
+ let socketDataMsgPack = (0, msgpack_1.encode)(socketData);
89559
+ socket.emit(Commands_1.Commands.EventCmd_MsgPack, socketDataMsgPack);
89560
+ }
89561
+ else {
89552
89562
  socket.emit(Commands_1.Commands.EventCmd_Json, socketData);
89563
+ }
89553
89564
  }
89554
89565
  sendEventTo(userId, operationEvent) {
89555
89566
  return __awaiter(this, void 0, void 0, function* () {
89556
89567
  let socketData = OperationHelper_1.OperationHelper.toEventSocketData(operationEvent);
89557
89568
  if (this.enableSendAndReceiveDebug)
89558
89569
  xDebug_1.Debug.log("[EVENT SEND EVENT TO] " + userId + " %O", JSON.stringify(socketData));
89559
- if (operationEvent.isEncrypted())
89560
- this.emitter.to(userId).emit(Commands_1.Commands.EventCmd_MsgPack, (0, msgpack_1.encode)(socketData));
89561
- else
89562
- this.emitter.to(userId).emit(Commands_1.Commands.EventCmd_Json, socketData);
89570
+ if (operationEvent.isEncrypted()) {
89571
+ let socketDataMsgPack = (0, msgpack_1.encode)(socketData);
89572
+ if (this.emitter != null)
89573
+ this.emitter.to(userId).emit(Commands_1.Commands.EventCmd_MsgPack, socketDataMsgPack);
89574
+ else
89575
+ this.server.to(userId).emit(Commands_1.Commands.EventCmd_MsgPack, (0, msgpack_1.encode)(socketData));
89576
+ }
89577
+ else {
89578
+ if (this.emitter != null)
89579
+ this.emitter.to(userId).emit(Commands_1.Commands.EventCmd_Json, socketData);
89580
+ else
89581
+ this.server.to(userId).emit(Commands_1.Commands.EventCmd_Json, socketData);
89582
+ }
89563
89583
  });
89564
89584
  }
89565
89585
  sendEventToRoom(roomId, operationEvent) {
@@ -89567,10 +89587,19 @@ class SocketAppHandler {
89567
89587
  let socketData = OperationHelper_1.OperationHelper.toEventSocketData(operationEvent);
89568
89588
  if (this.enableSendAndReceiveDebug)
89569
89589
  xDebug_1.Debug.log("[EVENT SEND EVENT TO ROOM] " + roomId + " %O", JSON.stringify(socketData));
89570
- if (operationEvent.isEncrypted())
89571
- this.emitter.to(roomId).emit(Commands_1.Commands.EventCmd_MsgPack, (0, msgpack_1.encode)(socketData));
89572
- else
89573
- this.emitter.to(roomId).emit(Commands_1.Commands.EventCmd_Json, socketData);
89590
+ if (operationEvent.isEncrypted()) {
89591
+ let socketDataMsgPack = (0, msgpack_1.encode)(socketData);
89592
+ if (this.emitter != null)
89593
+ this.emitter.to(roomId).emit(Commands_1.Commands.EventCmd_MsgPack, socketDataMsgPack);
89594
+ else
89595
+ this.server.to(roomId).emit(Commands_1.Commands.EventCmd_MsgPack, (0, msgpack_1.encode)(socketData));
89596
+ }
89597
+ else {
89598
+ if (this.emitter != null)
89599
+ this.emitter.to(roomId).emit(Commands_1.Commands.EventCmd_Json, socketData);
89600
+ else
89601
+ this.server.to(roomId).emit(Commands_1.Commands.EventCmd_Json, socketData);
89602
+ }
89574
89603
  });
89575
89604
  }
89576
89605
  sendEventToMoreUser(userIds, operationEvent) {
@@ -89580,16 +89609,16 @@ class SocketAppHandler {
89580
89609
  xDebug_1.Debug.log("[EVENT SEND EVENT TO MORE USER] %O", JSON.stringify(socketData));
89581
89610
  if (operationEvent.isEncrypted()) {
89582
89611
  let socketDataMsgPack = (0, msgpack_1.encode)(socketData);
89583
- for (let i = 0; i < userIds.length; i++) {
89584
- let userId = userIds[i];
89585
- this.emitter.to(userId).emit(Commands_1.Commands.EventCmd_MsgPack, socketDataMsgPack);
89586
- }
89612
+ if (this.emitter != null)
89613
+ this.emitter.to(userIds).emit(Commands_1.Commands.EventCmd_MsgPack, socketDataMsgPack);
89614
+ else
89615
+ this.server.to(userIds).emit(Commands_1.Commands.EventCmd_MsgPack, socketDataMsgPack);
89587
89616
  }
89588
89617
  else {
89589
- for (let i = 0; i < userIds.length; i++) {
89590
- let userId = userIds[i];
89591
- this.emitter.to(userId).emit(Commands_1.Commands.EventCmd_Json, socketData);
89592
- }
89618
+ if (this.emitter != null)
89619
+ this.emitter.to(userIds).emit(Commands_1.Commands.EventCmd_Json, socketData);
89620
+ else
89621
+ this.server.to(userIds).emit(Commands_1.Commands.EventCmd_Json, socketData);
89593
89622
  }
89594
89623
  });
89595
89624
  }
@@ -89598,10 +89627,19 @@ class SocketAppHandler {
89598
89627
  let socketData = OperationHelper_1.OperationHelper.toEventSocketData(operationEvent);
89599
89628
  if (this.enableSendAndReceiveDebug)
89600
89629
  xDebug_1.Debug.log("[EVENT SEND EVENT TO ALL PLAYER] %O", JSON.stringify(socketData));
89601
- if (operationEvent.isEncrypted())
89602
- this.emitter.of("/").emit(Commands_1.Commands.EventCmd_MsgPack, (0, msgpack_1.encode)(socketData));
89603
- else
89604
- this.emitter.of("/").emit(Commands_1.Commands.EventCmd_Json, socketData);
89630
+ if (operationEvent.isEncrypted()) {
89631
+ let socketDataMsgPack = (0, msgpack_1.encode)(socketData);
89632
+ if (this.emitter != null)
89633
+ this.emitter.emit(Commands_1.Commands.EventCmd_MsgPack, socketDataMsgPack);
89634
+ else
89635
+ this.server.emit(Commands_1.Commands.EventCmd_MsgPack, socketDataMsgPack);
89636
+ }
89637
+ else {
89638
+ if (this.emitter != null)
89639
+ this.emitter.emit(Commands_1.Commands.EventCmd_Json, socketData);
89640
+ else
89641
+ this.server.emit(Commands_1.Commands.EventCmd_Json, socketData);
89642
+ }
89605
89643
  });
89606
89644
  }
89607
89645
  sendEventToNamespace(namespace, operationEvent) {
@@ -89609,10 +89647,19 @@ class SocketAppHandler {
89609
89647
  let socketData = OperationHelper_1.OperationHelper.toEventSocketData(operationEvent);
89610
89648
  if (this.enableSendAndReceiveDebug)
89611
89649
  xDebug_1.Debug.log("[EVENT SEND EVENT TO NAME SPACE] %O", JSON.stringify(socketData));
89612
- if (operationEvent.isEncrypted())
89613
- this.emitter.of("/" + namespace).emit(Commands_1.Commands.EventCmd_MsgPack, (0, msgpack_1.encode)(socketData));
89614
- else
89615
- this.emitter.of("/" + namespace).emit(Commands_1.Commands.EventCmd_Json, socketData);
89650
+ if (operationEvent.isEncrypted()) {
89651
+ let socketDataMsgPack = (0, msgpack_1.encode)(socketData);
89652
+ if (this.emitter != null)
89653
+ this.emitter.of("/" + namespace).emit(Commands_1.Commands.EventCmd_MsgPack, socketDataMsgPack);
89654
+ else
89655
+ this.server.of("/" + namespace).emit(Commands_1.Commands.EventCmd_MsgPack, socketDataMsgPack);
89656
+ }
89657
+ else {
89658
+ if (this.emitter != null)
89659
+ this.emitter.of("/" + namespace).emit(Commands_1.Commands.EventCmd_Json, socketData);
89660
+ else
89661
+ this.server.of("/" + namespace).emit(Commands_1.Commands.EventCmd_Json, socketData);
89662
+ }
89616
89663
  });
89617
89664
  }
89618
89665
  getSocketViaSocketId(socketId) {
@@ -90300,6 +90347,9 @@ class BuilderBase {
90300
90347
  getEnable() {
90301
90348
  return this.enable;
90302
90349
  }
90350
+ getUseEmitter() {
90351
+ return this.useEmitter;
90352
+ }
90303
90353
  getOrigin() {
90304
90354
  return this.origin;
90305
90355
  }
@@ -90375,6 +90425,10 @@ class Builder extends BuilderBase {
90375
90425
  this.enable = enable;
90376
90426
  return this;
90377
90427
  }
90428
+ setUseEmitter(useEmitter) {
90429
+ this.useEmitter = useEmitter;
90430
+ return this;
90431
+ }
90378
90432
  setEnableSendAndReceiveDebug(enableSendAndReceiveDebug) {
90379
90433
  this.enableSendAndReceiveDebug = enableSendAndReceiveDebug;
90380
90434
  return this;
@@ -90390,6 +90444,7 @@ class Builder extends BuilderBase {
90390
90444
  constructor() {
90391
90445
  super();
90392
90446
  this.enable = false;
90447
+ this.useEmitter = false;
90393
90448
  this.origin = "";
90394
90449
  this.methods = [];
90395
90450
  this.allowedHeaders = [];
@@ -90412,6 +90467,7 @@ class SocketAppSettings extends BuilderBase {
90412
90467
  this.origin = builder.getOrigin();
90413
90468
  this.methods = builder.getMethods();
90414
90469
  this.enable = builder.getEnable();
90470
+ this.useEmitter = builder.getUseEmitter();
90415
90471
  this.allowedHeaders = builder.getAllowedHeaders();
90416
90472
  this.credentials = builder.getCredentials();
90417
90473
  this.enableSendAndReceiveDebug = builder.getEnableSendAndReceiveDebug();
package/gn.sh CHANGED
@@ -111,6 +111,7 @@ init_create_GNConfigDebugJson() {
111
111
 
112
112
  "socketAppSettings": {
113
113
  "enable": true,
114
+ "useEmitter": false,
114
115
  "allowOrigin": "*",
115
116
  "credentials": true,
116
117
  "allowMethods": ["GET"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xmobitea/gn-server",
3
- "version": "2.4.2",
3
+ "version": "2.4.4",
4
4
  "description": "Game Networking Server by XmobiTea (Pro)",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",