@xmobitea/gn-server 2.6.0 → 2.6.1
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-app-api/handler/controller/handler/dashboard/model/EmailSettingsParam.d.ts +5 -1
- package/dist/GN-app-api/service/EmailService.d.ts +9 -4
- package/dist/GN-app-api/service/IEmailService.d.ts +2 -2
- package/dist/GN-app-api/service/IPlayStationNetworkService.d.ts +5 -0
- package/dist/GN-app-api/service/ISteamService.d.ts +5 -0
- package/dist/GN-app-api/service/PlayStationNetworkService.d.ts +14 -0
- package/dist/GN-app-api/service/SteamService.d.ts +12 -0
- package/dist/GN-common/constant/parameterCode/GNParameterCode.d.ts +3 -0
- package/dist/GN-library/xsettings/lib/entity/xEmailSettings.d.ts +5 -1
- package/dist/GN-startup/routes/SocketAppHandler.d.ts +7 -8
- package/dist/GNServer.d.ts +6 -2
- package/dist/index.js +207 -92
- package/package.json +4 -3
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { IEmailService, OnSendMailError, OnSendMailSuccess } from "./IEmailService";
|
|
2
2
|
export declare class EmailService implements IEmailService {
|
|
3
3
|
private isInit;
|
|
4
|
-
private
|
|
4
|
+
private host;
|
|
5
|
+
private port;
|
|
6
|
+
private secure;
|
|
7
|
+
private username;
|
|
8
|
+
private password;
|
|
5
9
|
private fromEmail;
|
|
6
10
|
private needSetup;
|
|
7
|
-
|
|
11
|
+
private transporter;
|
|
12
|
+
init(host: string, port: number, secure: boolean, username: string, password: string, fromEmail: string): void;
|
|
8
13
|
run(): void;
|
|
9
|
-
sendMail(toEmail: string, subject: string, contentHtml: string, onSendMailSuccess?: OnSendMailSuccess, onSendMailError?: OnSendMailError):
|
|
10
|
-
sendMailToMore(toEmails: string[], subject: string, contentHtml: string, onSendMailSuccess?: OnSendMailSuccess, onSendMailError?: OnSendMailError):
|
|
14
|
+
sendMail(toEmail: string, subject: string, contentHtml: string, onSendMailSuccess?: OnSendMailSuccess, onSendMailError?: OnSendMailError): void;
|
|
15
|
+
sendMailToMore(toEmails: string[], subject: string, contentHtml: string, onSendMailSuccess?: OnSendMailSuccess, onSendMailError?: OnSendMailError): void;
|
|
11
16
|
}
|
|
@@ -5,6 +5,6 @@ export interface OnSendMailError {
|
|
|
5
5
|
(error: string): void;
|
|
6
6
|
}
|
|
7
7
|
export interface IEmailService {
|
|
8
|
-
sendMail(toEmail: string, subject: string, contentHtml: string, onSendMailSuccess?: OnSendMailSuccess, onSendMailError?: OnSendMailError):
|
|
9
|
-
sendMailToMore(toEmails: string[], subject: string, contentHtml: string, onSendMailSuccess?: OnSendMailSuccess, onSendMailError?: OnSendMailError):
|
|
8
|
+
sendMail(toEmail: string, subject: string, contentHtml: string, onSendMailSuccess?: OnSendMailSuccess, onSendMailError?: OnSendMailError): void;
|
|
9
|
+
sendMailToMore(toEmails: string[], subject: string, contentHtml: string, onSendMailSuccess?: OnSendMailSuccess, onSendMailError?: OnSendMailError): void;
|
|
10
10
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IPlayStationNetworkService } from "./IPlayStationNetworkService";
|
|
2
|
+
export declare class PlayStationNetworkService implements IPlayStationNetworkService {
|
|
3
|
+
private static readonly MAIN_iss;
|
|
4
|
+
private static readonly MAIN_iss_auth_keys;
|
|
5
|
+
private client;
|
|
6
|
+
private appleClientId;
|
|
7
|
+
constructor();
|
|
8
|
+
init(): void;
|
|
9
|
+
private getSigningKey;
|
|
10
|
+
private verifyToken;
|
|
11
|
+
verifyPSNToken(token: string): Promise<{
|
|
12
|
+
[k: string]: any;
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ISteamService } from "./ISteamService";
|
|
2
|
+
export declare class SteamService implements ISteamService {
|
|
3
|
+
private steamApiKey;
|
|
4
|
+
private steamAppId;
|
|
5
|
+
init(request: {
|
|
6
|
+
steamApiKey: string;
|
|
7
|
+
steamAppId: string;
|
|
8
|
+
}): void;
|
|
9
|
+
verifyTicket(ticket: string, identity: string): Promise<{
|
|
10
|
+
[k: string]: any;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
@@ -549,6 +549,9 @@ export declare class GNParameterCode {
|
|
|
549
549
|
static readonly PushNotificationSettings: string;
|
|
550
550
|
static readonly SendFrom: string;
|
|
551
551
|
static readonly SendGridApiKey: string;
|
|
552
|
+
static readonly Host: string;
|
|
553
|
+
static readonly Port: string;
|
|
554
|
+
static readonly Secure: string;
|
|
552
555
|
static readonly Subject: string;
|
|
553
556
|
static readonly ContentHtml: string;
|
|
554
557
|
static readonly PushNotifications: string;
|
|
@@ -44,16 +44,15 @@ export declare class SocketAppHandler {
|
|
|
44
44
|
private onSocketResponse;
|
|
45
45
|
private onSocketDisconnect;
|
|
46
46
|
private sendResponseForSocket;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
sendEventToNamespace(namespace: string, operationEvent: OperationEvent): Promise<void>;
|
|
47
|
+
sendEventTo(userId: string, operationEvent: OperationEvent, useMsgPack?: boolean): void;
|
|
48
|
+
sendEventToRoom(roomId: string, operationEvent: OperationEvent, useMsgPack?: boolean): void;
|
|
49
|
+
sendEventToMoreUser(userIds: string[], operationEvent: OperationEvent, useMsgPack?: boolean): void;
|
|
50
|
+
sendEventToAllPlayer(operationEvent: OperationEvent, useMsgPack?: boolean): void;
|
|
51
|
+
sendEventToNamespace(namespace: string, operationEvent: OperationEvent): void;
|
|
53
52
|
getSocketViaSocketId(socketId: string): Socket;
|
|
54
53
|
getSockets(userId: string): import("socket.io").BroadcastOperator<import("socket.io/dist/typed-events").DecorateAcknowledgementsWithMultipleResponses<import("socket.io").DefaultEventsMap>, any>;
|
|
55
|
-
joinRoom(userId: string, roomId: string):
|
|
56
|
-
leaveRoom(userId: string, roomId: string):
|
|
54
|
+
joinRoom(userId: string, roomId: string): void;
|
|
55
|
+
leaveRoom(userId: string, roomId: string): void;
|
|
57
56
|
getRooms(userId: string): Promise<string[]>;
|
|
58
57
|
}
|
|
59
58
|
export {};
|
package/dist/GNServer.d.ts
CHANGED
|
@@ -103,11 +103,15 @@ export declare class GNServer {
|
|
|
103
103
|
getCloudScriptService(gameId: string): ICloudScriptService;
|
|
104
104
|
setCloudScriptService(gameId: string, cloudScriptService: ICloudScriptService): Map<string, ICloudScriptService>;
|
|
105
105
|
sendEventTo(userId: string, operationEvent: OperationEvent): Promise<void>;
|
|
106
|
+
private executeSendEventTo;
|
|
106
107
|
sendEventToRoom(roomId: string, operationEvent: OperationEvent): Promise<void>;
|
|
108
|
+
private executeSendEventToRoom;
|
|
107
109
|
sendEventToMoreUser(userIds: string[], operationEvent: OperationEvent): Promise<void>;
|
|
110
|
+
private executeSendEventToMoreUser;
|
|
108
111
|
sendEventToAllPlayer(operationEvent: OperationEvent): Promise<void>;
|
|
109
|
-
|
|
110
|
-
|
|
112
|
+
private executeSendEventToAllPlayer;
|
|
113
|
+
joinRoom(userId: string, roomId: string): void;
|
|
114
|
+
leaveRoom(userId: string, roomId: string): void;
|
|
111
115
|
getRooms(userId: string): Promise<string[]>;
|
|
112
116
|
private handleSocketDisconnect;
|
|
113
117
|
private handleOnRequest;
|
package/dist/index.js
CHANGED
|
@@ -1749,6 +1749,15 @@ class AppleService {
|
|
|
1749
1749
|
else if (answer.aud !== this.appleClientId) {
|
|
1750
1750
|
answer["error"] = "unexpected audience (aud claim): " + answer.aud;
|
|
1751
1751
|
}
|
|
1752
|
+
else {
|
|
1753
|
+
let now = Math.floor(Date.now() / 1000); // thời gian hiện tại (epoch seconds)
|
|
1754
|
+
if (answer.exp && answer.exp < now) {
|
|
1755
|
+
answer["error"] = "token expired at " + new Date(answer.exp * 1000).toISOString();
|
|
1756
|
+
}
|
|
1757
|
+
else if (answer.iat && answer.iat > now + 10) {
|
|
1758
|
+
answer["error"] = "token issued in the future: " + new Date(answer.iat * 1000).toISOString();
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1752
1761
|
return answer;
|
|
1753
1762
|
}
|
|
1754
1763
|
catch (error) {
|
|
@@ -2532,6 +2541,9 @@ class GNParameterCode {
|
|
|
2532
2541
|
static PushNotificationSettings = "pushNotificationSettings";
|
|
2533
2542
|
static SendFrom = "sendFrom";
|
|
2534
2543
|
static SendGridApiKey = "sendGridApiKey";
|
|
2544
|
+
static Host = "host";
|
|
2545
|
+
static Port = "port";
|
|
2546
|
+
static Secure = "secure";
|
|
2535
2547
|
static Subject = "subject";
|
|
2536
2548
|
static ContentHtml = "contentHtml";
|
|
2537
2549
|
static PushNotifications = "pushNotifications";
|
|
@@ -5651,34 +5663,61 @@ class RequestConverterService {
|
|
|
5651
5663
|
}
|
|
5652
5664
|
}
|
|
5653
5665
|
|
|
5654
|
-
;// external "
|
|
5655
|
-
const
|
|
5656
|
-
var
|
|
5666
|
+
;// external "nodemailer"
|
|
5667
|
+
const external_nodemailer_namespaceObject = require("nodemailer");
|
|
5668
|
+
var external_nodemailer_default = /*#__PURE__*/__webpack_require__.n(external_nodemailer_namespaceObject);
|
|
5657
5669
|
;// ./src/GN-app-api/service/EmailService.ts
|
|
5658
5670
|
|
|
5659
5671
|
class EmailService {
|
|
5660
5672
|
isInit = false;
|
|
5661
|
-
|
|
5673
|
+
host;
|
|
5674
|
+
port;
|
|
5675
|
+
secure;
|
|
5676
|
+
username;
|
|
5677
|
+
password;
|
|
5662
5678
|
fromEmail;
|
|
5663
5679
|
needSetup = false;
|
|
5664
|
-
|
|
5680
|
+
transporter;
|
|
5681
|
+
init(host, port, secure, username, password, fromEmail) {
|
|
5665
5682
|
this.isInit = false;
|
|
5666
|
-
let
|
|
5667
|
-
|
|
5683
|
+
let oldHost = this.host;
|
|
5684
|
+
let oldPort = this.port;
|
|
5685
|
+
let oldSecure = this.secure;
|
|
5686
|
+
let oldUsername = this.username;
|
|
5687
|
+
let oldPassword = this.password;
|
|
5688
|
+
this.host = host;
|
|
5689
|
+
this.port = port;
|
|
5690
|
+
this.secure = secure;
|
|
5691
|
+
this.username = username;
|
|
5692
|
+
this.password = password;
|
|
5668
5693
|
this.fromEmail = fromEmail;
|
|
5669
|
-
if (
|
|
5694
|
+
if (oldHost != host || oldPort != port || oldSecure != secure || oldUsername != username || oldPassword != password) {
|
|
5670
5695
|
this.needSetup = true;
|
|
5671
5696
|
}
|
|
5672
5697
|
}
|
|
5673
5698
|
run() {
|
|
5674
|
-
if (!this.
|
|
5699
|
+
if (!this.host)
|
|
5700
|
+
return;
|
|
5701
|
+
if (!this.port)
|
|
5702
|
+
return;
|
|
5703
|
+
if (!this.username)
|
|
5704
|
+
return;
|
|
5705
|
+
if (!this.password)
|
|
5675
5706
|
return;
|
|
5676
5707
|
if (!this.needSetup)
|
|
5677
5708
|
return;
|
|
5678
|
-
|
|
5709
|
+
this.transporter = external_nodemailer_default().createTransport({
|
|
5710
|
+
host: this.host,
|
|
5711
|
+
port: this.port,
|
|
5712
|
+
secure: this.secure,
|
|
5713
|
+
auth: {
|
|
5714
|
+
user: this.username,
|
|
5715
|
+
pass: this.password,
|
|
5716
|
+
}
|
|
5717
|
+
});
|
|
5679
5718
|
this.isInit = true;
|
|
5680
5719
|
}
|
|
5681
|
-
|
|
5720
|
+
sendMail(toEmail, subject, contentHtml, onSendMailSuccess, onSendMailError) {
|
|
5682
5721
|
if (!this.isInit)
|
|
5683
5722
|
return;
|
|
5684
5723
|
let msg = {
|
|
@@ -5687,24 +5726,18 @@ class EmailService {
|
|
|
5687
5726
|
subject: subject,
|
|
5688
5727
|
html: contentHtml,
|
|
5689
5728
|
};
|
|
5690
|
-
|
|
5691
|
-
|
|
5692
|
-
let statusCode = response;
|
|
5693
|
-
if (statusCode > 399) {
|
|
5729
|
+
this.transporter.sendMail(msg, (error, info) => {
|
|
5730
|
+
if (error) {
|
|
5694
5731
|
if (onSendMailError != null)
|
|
5695
|
-
onSendMailError(
|
|
5732
|
+
onSendMailError(error.message);
|
|
5696
5733
|
}
|
|
5697
5734
|
else {
|
|
5698
5735
|
if (onSendMailSuccess != null)
|
|
5699
5736
|
onSendMailSuccess();
|
|
5700
5737
|
}
|
|
5701
|
-
}
|
|
5702
|
-
catch (err) {
|
|
5703
|
-
if (onSendMailError != null)
|
|
5704
|
-
onSendMailError(err.message);
|
|
5705
|
-
}
|
|
5738
|
+
});
|
|
5706
5739
|
}
|
|
5707
|
-
|
|
5740
|
+
sendMailToMore(toEmails, subject, contentHtml, onSendMailSuccess, onSendMailError) {
|
|
5708
5741
|
if (!this.isInit)
|
|
5709
5742
|
return;
|
|
5710
5743
|
let msg = {
|
|
@@ -5713,22 +5746,16 @@ class EmailService {
|
|
|
5713
5746
|
subject: subject,
|
|
5714
5747
|
html: contentHtml,
|
|
5715
5748
|
};
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
let statusCode = response;
|
|
5719
|
-
if (statusCode > 399) {
|
|
5749
|
+
this.transporter.sendMail(msg, (error, info) => {
|
|
5750
|
+
if (error) {
|
|
5720
5751
|
if (onSendMailError != null)
|
|
5721
|
-
onSendMailError(
|
|
5752
|
+
onSendMailError(error.message);
|
|
5722
5753
|
}
|
|
5723
5754
|
else {
|
|
5724
5755
|
if (onSendMailSuccess != null)
|
|
5725
5756
|
onSendMailSuccess();
|
|
5726
5757
|
}
|
|
5727
|
-
}
|
|
5728
|
-
catch (err) {
|
|
5729
|
-
if (onSendMailError != null)
|
|
5730
|
-
onSendMailError(err.message);
|
|
5731
|
-
}
|
|
5758
|
+
});
|
|
5732
5759
|
}
|
|
5733
5760
|
}
|
|
5734
5761
|
|
|
@@ -15336,15 +15363,10 @@ class HttpAppHandler {
|
|
|
15336
15363
|
Debug.log("[HTTP SEND] %O", JSON.stringify(httpData));
|
|
15337
15364
|
}
|
|
15338
15365
|
if (operationResponse.isEncrypted()) {
|
|
15339
|
-
|
|
15340
|
-
res.setHeader(Commands.CONTENT_TYPE, Commands.APPLICATION_MSGPACK);
|
|
15341
|
-
res.setHeader(Commands.CONTENT_LENGTH, content.length);
|
|
15342
|
-
return res.send(content);
|
|
15343
|
-
}
|
|
15344
|
-
else {
|
|
15345
|
-
res.setHeader(Commands.CONTENT_TYPE, Commands.APPLICATION_JSON);
|
|
15346
|
-
return res.send(httpData);
|
|
15366
|
+
// TODO Encrypt data here
|
|
15347
15367
|
}
|
|
15368
|
+
res.setHeader(Commands.CONTENT_TYPE, Commands.APPLICATION_JSON);
|
|
15369
|
+
return res.send(httpData);
|
|
15348
15370
|
}
|
|
15349
15371
|
res.setHeader(Commands.CONTENT_TYPE, Commands.APPLICATION_JSON);
|
|
15350
15372
|
return res.send([ReturnCode.OperationInvalid]);
|
|
@@ -15390,16 +15412,12 @@ class HttpAppHandler {
|
|
|
15390
15412
|
Debug.log("[HTTP SEND] %O", JSON.stringify(httpData));
|
|
15391
15413
|
}
|
|
15392
15414
|
if (operationResponse.isEncrypted()) {
|
|
15393
|
-
|
|
15394
|
-
res.setHeader(Commands.CONTENT_TYPE, Commands.APPLICATION_MSGPACK);
|
|
15395
|
-
res.setHeader(Commands.CONTENT_LENGTH, content.length);
|
|
15396
|
-
return res.send(content);
|
|
15397
|
-
}
|
|
15398
|
-
else {
|
|
15399
|
-
let content = httpData;
|
|
15400
|
-
res.setHeader(Commands.CONTENT_TYPE, Commands.APPLICATION_JSON);
|
|
15401
|
-
return res.send(content);
|
|
15415
|
+
// TODO Encrypt data here
|
|
15402
15416
|
}
|
|
15417
|
+
let content = Buffer.from((0,msgpack_namespaceObject.encode)(httpData));
|
|
15418
|
+
res.setHeader(Commands.CONTENT_TYPE, Commands.APPLICATION_MSGPACK);
|
|
15419
|
+
res.setHeader(Commands.CONTENT_LENGTH, content.length);
|
|
15420
|
+
return res.send(content);
|
|
15403
15421
|
}
|
|
15404
15422
|
let content = Buffer.from((0,msgpack_namespaceObject.encode)([ReturnCode.OperationInvalid]));
|
|
15405
15423
|
res.setHeader(Commands.CONTENT_TYPE, Commands.APPLICATION_MSGPACK);
|
|
@@ -15518,7 +15536,7 @@ class SocketAppHandler {
|
|
|
15518
15536
|
this.apiMiddleware.socketAuthenticateToken(socket, async (returnCode) => {
|
|
15519
15537
|
let operationResponse = await this.onSocketRequestMsgPack(socket, data, returnCode);
|
|
15520
15538
|
if (operationResponse != null) {
|
|
15521
|
-
this.sendResponseForSocket(socket, operationResponse);
|
|
15539
|
+
this.sendResponseForSocket(socket, operationResponse, true);
|
|
15522
15540
|
}
|
|
15523
15541
|
this.antiDdosMiddleware.removePendingRequestViaSocket(socket, data);
|
|
15524
15542
|
});
|
|
@@ -15537,7 +15555,7 @@ class SocketAppHandler {
|
|
|
15537
15555
|
this.apiMiddleware.socketAuthenticateToken(socket, async (returnCode) => {
|
|
15538
15556
|
let operationResponse = await this.onSocketRequestJson(socket, data, returnCode);
|
|
15539
15557
|
if (operationResponse != null) {
|
|
15540
|
-
this.sendResponseForSocket(socket, operationResponse);
|
|
15558
|
+
this.sendResponseForSocket(socket, operationResponse, false);
|
|
15541
15559
|
}
|
|
15542
15560
|
this.antiDdosMiddleware.removePendingRequestViaSocket(socket, data);
|
|
15543
15561
|
});
|
|
@@ -15720,11 +15738,14 @@ class SocketAppHandler {
|
|
|
15720
15738
|
if (this._onDisconnectCb != null)
|
|
15721
15739
|
this._onDisconnectCb(socket, data);
|
|
15722
15740
|
}
|
|
15723
|
-
sendResponseForSocket(socket, operationResponse) {
|
|
15741
|
+
sendResponseForSocket(socket, operationResponse, useMsgPack) {
|
|
15724
15742
|
let socketData = OperationHelper.toResponseSocketData(operationResponse);
|
|
15725
15743
|
if (this.enableSendAndReceiveDebug)
|
|
15726
15744
|
Debug.log("[SOCKET SEND] %O", JSON.stringify(socketData));
|
|
15727
15745
|
if (operationResponse.isEncrypted()) {
|
|
15746
|
+
// TODO Encrypt data
|
|
15747
|
+
}
|
|
15748
|
+
if (useMsgPack) {
|
|
15728
15749
|
let socketDataMsgPack = (0,msgpack_namespaceObject.encode)(socketData);
|
|
15729
15750
|
socket.emit(Commands.ResponseCmd_MsgPack, socketDataMsgPack);
|
|
15730
15751
|
}
|
|
@@ -15732,28 +15753,32 @@ class SocketAppHandler {
|
|
|
15732
15753
|
socket.emit(Commands.ResponseCmd_Json, socketData);
|
|
15733
15754
|
}
|
|
15734
15755
|
}
|
|
15735
|
-
sendEventForSocket(socket, operationEvent) {
|
|
15736
|
-
|
|
15737
|
-
|
|
15738
|
-
|
|
15739
|
-
|
|
15740
|
-
|
|
15741
|
-
|
|
15742
|
-
|
|
15743
|
-
|
|
15744
|
-
|
|
15745
|
-
|
|
15746
|
-
}
|
|
15747
|
-
|
|
15756
|
+
// private sendEventForSocket(socket: Socket, operationEvent: OperationEvent) {
|
|
15757
|
+
// let socketData = OperationHelper.toEventSocketData(operationEvent);
|
|
15758
|
+
// if (this.enableSendAndReceiveDebug) Debug.log("[EVENT SEND] %O", JSON.stringify(socketData));
|
|
15759
|
+
// if (operationEvent.isEncrypted())
|
|
15760
|
+
// {
|
|
15761
|
+
// let socketDataMsgPack = encode(socketData);
|
|
15762
|
+
// socket.emit(Commands.EventCmd_MsgPack, socketDataMsgPack);
|
|
15763
|
+
// }
|
|
15764
|
+
// else
|
|
15765
|
+
// {
|
|
15766
|
+
// socket.emit(Commands.EventCmd_Json, socketData);
|
|
15767
|
+
// }
|
|
15768
|
+
// }
|
|
15769
|
+
sendEventTo(userId, operationEvent, useMsgPack = true) {
|
|
15748
15770
|
let socketData = OperationHelper.toEventSocketData(operationEvent);
|
|
15749
15771
|
if (this.enableSendAndReceiveDebug)
|
|
15750
15772
|
Debug.log("[EVENT SEND EVENT TO] " + userId + " %O", JSON.stringify(socketData));
|
|
15751
15773
|
if (operationEvent.isEncrypted()) {
|
|
15774
|
+
// TODO Encrypt data
|
|
15775
|
+
}
|
|
15776
|
+
if (useMsgPack) {
|
|
15752
15777
|
let socketDataMsgPack = (0,msgpack_namespaceObject.encode)(socketData);
|
|
15753
15778
|
if (this.emitter != null)
|
|
15754
15779
|
this.emitter.to(userId).emit(Commands.EventCmd_MsgPack, socketDataMsgPack);
|
|
15755
15780
|
else
|
|
15756
|
-
this.server.to(userId).emit(Commands.EventCmd_MsgPack,
|
|
15781
|
+
this.server.to(userId).emit(Commands.EventCmd_MsgPack, socketDataMsgPack);
|
|
15757
15782
|
}
|
|
15758
15783
|
else {
|
|
15759
15784
|
if (this.emitter != null)
|
|
@@ -15762,16 +15787,19 @@ class SocketAppHandler {
|
|
|
15762
15787
|
this.server.to(userId).emit(Commands.EventCmd_Json, socketData);
|
|
15763
15788
|
}
|
|
15764
15789
|
}
|
|
15765
|
-
|
|
15790
|
+
sendEventToRoom(roomId, operationEvent, useMsgPack = true) {
|
|
15766
15791
|
let socketData = OperationHelper.toEventSocketData(operationEvent);
|
|
15767
15792
|
if (this.enableSendAndReceiveDebug)
|
|
15768
15793
|
Debug.log("[EVENT SEND EVENT TO ROOM] " + roomId + " %O", JSON.stringify(socketData));
|
|
15769
15794
|
if (operationEvent.isEncrypted()) {
|
|
15795
|
+
// TODO Encrypt data
|
|
15796
|
+
}
|
|
15797
|
+
if (useMsgPack) {
|
|
15770
15798
|
let socketDataMsgPack = (0,msgpack_namespaceObject.encode)(socketData);
|
|
15771
15799
|
if (this.emitter != null)
|
|
15772
15800
|
this.emitter.to(roomId).emit(Commands.EventCmd_MsgPack, socketDataMsgPack);
|
|
15773
15801
|
else
|
|
15774
|
-
this.server.to(roomId).emit(Commands.EventCmd_MsgPack,
|
|
15802
|
+
this.server.to(roomId).emit(Commands.EventCmd_MsgPack, socketDataMsgPack);
|
|
15775
15803
|
}
|
|
15776
15804
|
else {
|
|
15777
15805
|
if (this.emitter != null)
|
|
@@ -15780,11 +15808,14 @@ class SocketAppHandler {
|
|
|
15780
15808
|
this.server.to(roomId).emit(Commands.EventCmd_Json, socketData);
|
|
15781
15809
|
}
|
|
15782
15810
|
}
|
|
15783
|
-
|
|
15811
|
+
sendEventToMoreUser(userIds, operationEvent, useMsgPack = true) {
|
|
15784
15812
|
let socketData = OperationHelper.toEventSocketData(operationEvent);
|
|
15785
15813
|
if (this.enableSendAndReceiveDebug)
|
|
15786
15814
|
Debug.log("[EVENT SEND EVENT TO MORE USER] %O", JSON.stringify(socketData));
|
|
15787
15815
|
if (operationEvent.isEncrypted()) {
|
|
15816
|
+
// TODO Encrypt data
|
|
15817
|
+
}
|
|
15818
|
+
if (useMsgPack) {
|
|
15788
15819
|
let socketDataMsgPack = (0,msgpack_namespaceObject.encode)(socketData);
|
|
15789
15820
|
if (this.emitter != null)
|
|
15790
15821
|
this.emitter.to(userIds).emit(Commands.EventCmd_MsgPack, socketDataMsgPack);
|
|
@@ -15798,11 +15829,14 @@ class SocketAppHandler {
|
|
|
15798
15829
|
this.server.to(userIds).emit(Commands.EventCmd_Json, socketData);
|
|
15799
15830
|
}
|
|
15800
15831
|
}
|
|
15801
|
-
|
|
15832
|
+
sendEventToAllPlayer(operationEvent, useMsgPack = true) {
|
|
15802
15833
|
let socketData = OperationHelper.toEventSocketData(operationEvent);
|
|
15803
15834
|
if (this.enableSendAndReceiveDebug)
|
|
15804
15835
|
Debug.log("[EVENT SEND EVENT TO ALL PLAYER] %O", JSON.stringify(socketData));
|
|
15805
15836
|
if (operationEvent.isEncrypted()) {
|
|
15837
|
+
// TODO Encrypt data
|
|
15838
|
+
}
|
|
15839
|
+
if (useMsgPack) {
|
|
15806
15840
|
let socketDataMsgPack = (0,msgpack_namespaceObject.encode)(socketData);
|
|
15807
15841
|
if (this.emitter != null)
|
|
15808
15842
|
this.emitter.emit(Commands.EventCmd_MsgPack, socketDataMsgPack);
|
|
@@ -15816,7 +15850,7 @@ class SocketAppHandler {
|
|
|
15816
15850
|
this.server.emit(Commands.EventCmd_Json, socketData);
|
|
15817
15851
|
}
|
|
15818
15852
|
}
|
|
15819
|
-
|
|
15853
|
+
sendEventToNamespace(namespace, operationEvent) {
|
|
15820
15854
|
let socketData = OperationHelper.toEventSocketData(operationEvent);
|
|
15821
15855
|
if (this.enableSendAndReceiveDebug)
|
|
15822
15856
|
Debug.log("[EVENT SEND EVENT TO NAME SPACE] %O", JSON.stringify(socketData));
|
|
@@ -15840,10 +15874,10 @@ class SocketAppHandler {
|
|
|
15840
15874
|
getSockets(userId) {
|
|
15841
15875
|
return this.server.in(userId);
|
|
15842
15876
|
}
|
|
15843
|
-
|
|
15877
|
+
joinRoom(userId, roomId) {
|
|
15844
15878
|
this.getSockets(userId).socketsJoin(roomId);
|
|
15845
15879
|
}
|
|
15846
|
-
|
|
15880
|
+
leaveRoom(userId, roomId) {
|
|
15847
15881
|
this.getSockets(userId).socketsLeave(roomId);
|
|
15848
15882
|
}
|
|
15849
15883
|
async getRooms(userId) {
|
|
@@ -70593,16 +70627,36 @@ var EmailSettingsParam_metadata = (undefined && undefined.__metadata) || functio
|
|
|
70593
70627
|
|
|
70594
70628
|
class EmailSettingsParam {
|
|
70595
70629
|
sendFrom;
|
|
70596
|
-
|
|
70630
|
+
secure;
|
|
70631
|
+
host;
|
|
70632
|
+
port;
|
|
70633
|
+
username;
|
|
70634
|
+
password;
|
|
70597
70635
|
}
|
|
70598
70636
|
EmailSettingsParam_decorate([
|
|
70599
70637
|
StringDataMember({ code: GNParameterCode.SendFrom }),
|
|
70600
70638
|
EmailSettingsParam_metadata("design:type", String)
|
|
70601
70639
|
], EmailSettingsParam.prototype, "sendFrom", void 0);
|
|
70602
70640
|
EmailSettingsParam_decorate([
|
|
70603
|
-
|
|
70641
|
+
BooleanDataMember({ code: GNParameterCode.Secure }),
|
|
70642
|
+
EmailSettingsParam_metadata("design:type", Boolean)
|
|
70643
|
+
], EmailSettingsParam.prototype, "secure", void 0);
|
|
70644
|
+
EmailSettingsParam_decorate([
|
|
70645
|
+
StringDataMember({ code: GNParameterCode.Host }),
|
|
70646
|
+
EmailSettingsParam_metadata("design:type", String)
|
|
70647
|
+
], EmailSettingsParam.prototype, "host", void 0);
|
|
70648
|
+
EmailSettingsParam_decorate([
|
|
70649
|
+
NumberDataMember({ code: GNParameterCode.Port }),
|
|
70650
|
+
EmailSettingsParam_metadata("design:type", Number)
|
|
70651
|
+
], EmailSettingsParam.prototype, "port", void 0);
|
|
70652
|
+
EmailSettingsParam_decorate([
|
|
70653
|
+
StringDataMember({ code: GNParameterCode.Username }),
|
|
70654
|
+
EmailSettingsParam_metadata("design:type", String)
|
|
70655
|
+
], EmailSettingsParam.prototype, "username", void 0);
|
|
70656
|
+
EmailSettingsParam_decorate([
|
|
70657
|
+
StringDataMember({ code: GNParameterCode.Password }),
|
|
70604
70658
|
EmailSettingsParam_metadata("design:type", String)
|
|
70605
|
-
], EmailSettingsParam.prototype, "
|
|
70659
|
+
], EmailSettingsParam.prototype, "password", void 0);
|
|
70606
70660
|
|
|
70607
70661
|
;// ./src/GN-app-api/handler/controller/handler/dashboard/model/PushNotificationSettingsParam.ts
|
|
70608
70662
|
var PushNotificationSettingsParam_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
@@ -71058,9 +71112,17 @@ class SetMasterGameSettingsRequestHandler extends RequestHandler {
|
|
|
71058
71112
|
let emailSettings = masterGameSettings.getEmailSettings();
|
|
71059
71113
|
if (request.emailSettings.sendFrom)
|
|
71060
71114
|
emailSettings.sendFrom = request.emailSettings.sendFrom;
|
|
71061
|
-
if (request.emailSettings.
|
|
71062
|
-
emailSettings.
|
|
71063
|
-
|
|
71115
|
+
if (request.emailSettings.secure != null)
|
|
71116
|
+
emailSettings.secure = request.emailSettings.secure;
|
|
71117
|
+
if (request.emailSettings.host)
|
|
71118
|
+
emailSettings.host = request.emailSettings.host;
|
|
71119
|
+
if (request.emailSettings.port)
|
|
71120
|
+
emailSettings.port = request.emailSettings.port;
|
|
71121
|
+
if (request.emailSettings.username)
|
|
71122
|
+
emailSettings.username = request.emailSettings.username;
|
|
71123
|
+
if (request.emailSettings.password)
|
|
71124
|
+
emailSettings.password = request.emailSettings.password;
|
|
71125
|
+
this.gnServer.getEmailService().init(emailSettings.host, emailSettings.port, emailSettings.secure, emailSettings.username, emailSettings.password, emailSettings.sendFrom);
|
|
71064
71126
|
this.gnServer.getEmailService().run();
|
|
71065
71127
|
masterGameSettings.setEmailSettings(emailSettings);
|
|
71066
71128
|
}
|
|
@@ -75583,7 +75645,11 @@ class GetMasterGameSettingsRequestHandler extends RequestHandler {
|
|
|
75583
75645
|
let emailSettings = masterGameSettings.getEmailSettings();
|
|
75584
75646
|
let gnEmailSettings = new GNHashtable();
|
|
75585
75647
|
gnEmailSettings.add(GNParameterCode.SendFrom, emailSettings.sendFrom);
|
|
75586
|
-
gnEmailSettings.add(GNParameterCode.
|
|
75648
|
+
gnEmailSettings.add(GNParameterCode.Host, emailSettings.host);
|
|
75649
|
+
gnEmailSettings.add(GNParameterCode.Port, emailSettings.port);
|
|
75650
|
+
gnEmailSettings.add(GNParameterCode.Secure, emailSettings.secure);
|
|
75651
|
+
gnEmailSettings.add(GNParameterCode.Username, emailSettings.username);
|
|
75652
|
+
gnEmailSettings.add(GNParameterCode.Password, emailSettings.password);
|
|
75587
75653
|
operationResponse.setParameter(GNParameterCode.EmailSettings, gnEmailSettings);
|
|
75588
75654
|
}
|
|
75589
75655
|
{
|
|
@@ -84844,6 +84910,8 @@ const GN_VERSION = "2.6";
|
|
|
84844
84910
|
|
|
84845
84911
|
|
|
84846
84912
|
|
|
84913
|
+
|
|
84914
|
+
|
|
84847
84915
|
|
|
84848
84916
|
|
|
84849
84917
|
|
|
@@ -85316,6 +85384,18 @@ class GNServer {
|
|
|
85316
85384
|
tempAnalyticsService.run();
|
|
85317
85385
|
this.analyticsService = tempAnalyticsService;
|
|
85318
85386
|
this.postEventCallbackCollection = this.xDatabase.systemCollection("EventCallback.Post");
|
|
85387
|
+
this.getHttpApp().getClusterHandler().onEvent("sendEventTo", data => {
|
|
85388
|
+
this.executeSendEventTo(data);
|
|
85389
|
+
});
|
|
85390
|
+
this.getHttpApp().getClusterHandler().onEvent("sendEventToRoom", data => {
|
|
85391
|
+
this.executeSendEventToRoom(data);
|
|
85392
|
+
});
|
|
85393
|
+
this.getHttpApp().getClusterHandler().onEvent("sendEventToMoreUser", data => {
|
|
85394
|
+
this.executeSendEventToMoreUser(data);
|
|
85395
|
+
});
|
|
85396
|
+
this.getHttpApp().getClusterHandler().onEvent("executeSendEventToAllPlayer", data => {
|
|
85397
|
+
this.executeSendEventToAllPlayer(data);
|
|
85398
|
+
});
|
|
85319
85399
|
if (onRunSuccess != null)
|
|
85320
85400
|
onRunSuccess();
|
|
85321
85401
|
}
|
|
@@ -85443,7 +85523,15 @@ class GNServer {
|
|
|
85443
85523
|
operationEvent: operationEventToData,
|
|
85444
85524
|
responseSize: Buffer.byteLength(JSON.stringify(operationEventToData), "utf-8"),
|
|
85445
85525
|
});
|
|
85446
|
-
|
|
85526
|
+
this.getHttpApp().getClusterHandler().sendEvent("sendEventTo", {
|
|
85527
|
+
userId: userId,
|
|
85528
|
+
operationEvent: operationEventToData,
|
|
85529
|
+
useMsgPack: true,
|
|
85530
|
+
});
|
|
85531
|
+
}
|
|
85532
|
+
executeSendEventTo(data) {
|
|
85533
|
+
let operationEvent = new OperationEvent(data.operationEvent.eventCode, data.operationEvent.parameters != null ? GNHashtable.builder().addAll(data.operationEvent.parameters).build() : null, data.operationEvent.encrypted);
|
|
85534
|
+
return this.socketApp.getSocketAppHandler().sendEventTo(data.userId, operationEvent, data.useMsgPack);
|
|
85447
85535
|
}
|
|
85448
85536
|
async sendEventToRoom(roomId, operationEvent) {
|
|
85449
85537
|
await this.eventCallbackCloudScriptService.executeEvent("system_SendEventToRoom", { roomId: roomId }, operationEvent);
|
|
@@ -85461,7 +85549,15 @@ class GNServer {
|
|
|
85461
85549
|
operationEvent: operationEventToData,
|
|
85462
85550
|
responseSize: Buffer.byteLength(JSON.stringify(operationEventToData), "utf-8"),
|
|
85463
85551
|
});
|
|
85464
|
-
|
|
85552
|
+
this.getHttpApp().getClusterHandler().sendEvent("sendEventToRoom", {
|
|
85553
|
+
roomId: roomId,
|
|
85554
|
+
operationEvent: operationEventToData,
|
|
85555
|
+
useMsgPack: true,
|
|
85556
|
+
});
|
|
85557
|
+
}
|
|
85558
|
+
executeSendEventToRoom(data) {
|
|
85559
|
+
let operationEvent = new OperationEvent(data.operationEvent.eventCode, data.operationEvent.parameters != null ? GNHashtable.builder().addAll(data.operationEvent.parameters).build() : null, data.operationEvent.encrypted);
|
|
85560
|
+
return this.socketApp.getSocketAppHandler().sendEventToRoom(data.roomId, operationEvent, data.useMsgPack);
|
|
85465
85561
|
}
|
|
85466
85562
|
async sendEventToMoreUser(userIds, operationEvent) {
|
|
85467
85563
|
await this.eventCallbackCloudScriptService.executeEvent("system_SendEventToMoreUser", { userIds: userIds }, operationEvent);
|
|
@@ -85479,7 +85575,15 @@ class GNServer {
|
|
|
85479
85575
|
operationEvent: operationEventToData,
|
|
85480
85576
|
responseSize: Buffer.byteLength(JSON.stringify(operationEventToData), "utf-8") * userIds.length,
|
|
85481
85577
|
});
|
|
85482
|
-
|
|
85578
|
+
this.getHttpApp().getClusterHandler().sendEvent("sendEventToMoreUser", {
|
|
85579
|
+
userIds: userIds,
|
|
85580
|
+
operationEvent: operationEventToData,
|
|
85581
|
+
useMsgPack: true,
|
|
85582
|
+
});
|
|
85583
|
+
}
|
|
85584
|
+
executeSendEventToMoreUser(data) {
|
|
85585
|
+
let operationEvent = new OperationEvent(data.operationEvent.eventCode, data.operationEvent.parameters != null ? GNHashtable.builder().addAll(data.operationEvent.parameters).build() : null, data.operationEvent.encrypted);
|
|
85586
|
+
return this.socketApp.getSocketAppHandler().sendEventToMoreUser(data.userIds, operationEvent, data.useMsgPack);
|
|
85483
85587
|
}
|
|
85484
85588
|
async sendEventToAllPlayer(operationEvent) {
|
|
85485
85589
|
await this.eventCallbackCloudScriptService.executeEvent("system_SendEventToAllPlayer", {}, operationEvent);
|
|
@@ -85495,16 +85599,23 @@ class GNServer {
|
|
|
85495
85599
|
operationEvent: operationEventToData,
|
|
85496
85600
|
responseSize: Buffer.byteLength(JSON.stringify(operationEventToData), "utf-8"),
|
|
85497
85601
|
});
|
|
85498
|
-
|
|
85602
|
+
this.getHttpApp().getClusterHandler().sendEvent("sendEventToAllPlayer", {
|
|
85603
|
+
operationEvent: operationEventToData,
|
|
85604
|
+
useMsgPack: true,
|
|
85605
|
+
});
|
|
85606
|
+
}
|
|
85607
|
+
executeSendEventToAllPlayer(data) {
|
|
85608
|
+
let operationEvent = new OperationEvent(data.operationEvent.eventCode, data.operationEvent.parameters != null ? GNHashtable.builder().addAll(data.operationEvent.parameters).build() : null, data.operationEvent.encrypted);
|
|
85609
|
+
return this.socketApp.getSocketAppHandler().sendEventToAllPlayer(operationEvent, data.useMsgPack);
|
|
85499
85610
|
}
|
|
85500
85611
|
// public async sendEventToNamespace(namespace: string, operationEvent: OperationEvent): Promise<void> {
|
|
85501
85612
|
// return await this.socketApp.getSocketAppHandler().sendEventToNamespace(namespace, operationEvent);
|
|
85502
85613
|
// }
|
|
85503
|
-
|
|
85504
|
-
return
|
|
85614
|
+
joinRoom(userId, roomId) {
|
|
85615
|
+
return this.socketApp.getSocketAppHandler().joinRoom(userId, roomId);
|
|
85505
85616
|
}
|
|
85506
|
-
|
|
85507
|
-
return
|
|
85617
|
+
leaveRoom(userId, roomId) {
|
|
85618
|
+
return this.socketApp.getSocketAppHandler().leaveRoom(userId, roomId);
|
|
85508
85619
|
}
|
|
85509
85620
|
async getRooms(userId) {
|
|
85510
85621
|
return await this.socketApp.getSocketAppHandler().getRooms(userId);
|
|
@@ -85597,6 +85708,8 @@ class GNServer {
|
|
|
85597
85708
|
|
|
85598
85709
|
;// external "@xmobitea/gn-typescript-client"
|
|
85599
85710
|
const gn_typescript_client_namespaceObject = require("@xmobitea/gn-typescript-client");
|
|
85711
|
+
;// external "@xmobitea/gn-typescript-client/dist/runtime/config/GNServerSettings"
|
|
85712
|
+
const GNServerSettings_namespaceObject = require("@xmobitea/gn-typescript-client/dist/runtime/config/GNServerSettings");
|
|
85600
85713
|
;// ./src/GN-startup/ServerApplication.ts
|
|
85601
85714
|
|
|
85602
85715
|
|
|
@@ -85620,6 +85733,7 @@ const gn_typescript_client_namespaceObject = require("@xmobitea/gn-typescript-cl
|
|
|
85620
85733
|
|
|
85621
85734
|
|
|
85622
85735
|
|
|
85736
|
+
|
|
85623
85737
|
|
|
85624
85738
|
|
|
85625
85739
|
class ServerApplication_BuilderBase {
|
|
@@ -85835,7 +85949,8 @@ class ServerApplication extends ServerApplication_BuilderBase {
|
|
|
85835
85949
|
useSsl: false,
|
|
85836
85950
|
useSocket: false,
|
|
85837
85951
|
useHttp: true,
|
|
85838
|
-
|
|
85952
|
+
messageType: GNServerSettings_namespaceObject.MessageType.MsgPack,
|
|
85953
|
+
sendRate: 2000,
|
|
85839
85954
|
reconnectDelay: 5000,
|
|
85840
85955
|
pingInterval: 20000,
|
|
85841
85956
|
pingTimeout: 20000,
|
|
@@ -86118,8 +86233,8 @@ class ServerApplication extends ServerApplication_BuilderBase {
|
|
|
86118
86233
|
this.gnServer.getApiMiddleware().updateSecretInfo(newSecretInfo);
|
|
86119
86234
|
}
|
|
86120
86235
|
}
|
|
86121
|
-
let
|
|
86122
|
-
let
|
|
86236
|
+
let username = process.env["GEARN_INIT_ROOT_USERNAME"] ?? "gearnadmin";
|
|
86237
|
+
let password = process.env["GEARN_INIT_ROOT_PASSWORD"] ?? "gearnpassword";
|
|
86123
86238
|
// create secretInfo for admin account
|
|
86124
86239
|
{
|
|
86125
86240
|
let permission = GrantSecretInfoRequestHandler.generateDefaultPermission(true, true, true, true);
|
|
@@ -86854,7 +86969,7 @@ class ServerApplication extends ServerApplication_BuilderBase {
|
|
|
86854
86969
|
}
|
|
86855
86970
|
{
|
|
86856
86971
|
let emailSettings = masterGameSettings.getEmailSettings();
|
|
86857
|
-
this.gnServer.getEmailService().init(emailSettings.
|
|
86972
|
+
this.gnServer.getEmailService().init(emailSettings.host, emailSettings.port, emailSettings.secure, emailSettings.username, emailSettings.password, emailSettings.sendFrom);
|
|
86858
86973
|
this.gnServer.getEmailService().run();
|
|
86859
86974
|
}
|
|
86860
86975
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xmobitea/gn-server",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"description": "GearN Server by XmobiTea (Pro)",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"@types/jsonwebtoken": "^9.0.7",
|
|
20
20
|
"@types/multer": "^1.4.12",
|
|
21
21
|
"@types/node": "^22.10.5",
|
|
22
|
+
"@types/nodemailer": "^6.4.17",
|
|
22
23
|
"terser-webpack-plugin": "^5.3.10",
|
|
23
24
|
"ts-loader": "^9.5.1",
|
|
24
25
|
"typescript": "^5.7.2",
|
|
@@ -28,10 +29,9 @@
|
|
|
28
29
|
},
|
|
29
30
|
"dependencies": {
|
|
30
31
|
"@msgpack/msgpack": "^2.8.0",
|
|
31
|
-
"@sendgrid/mail": "^8.1.4",
|
|
32
32
|
"@socket.io/mongo-adapter": "^0.3.2",
|
|
33
33
|
"@socket.io/mongo-emitter": "^0.2.0",
|
|
34
|
-
"@xmobitea/gn-typescript-client": "^2.6.
|
|
34
|
+
"@xmobitea/gn-typescript-client": "^2.6.2",
|
|
35
35
|
"axios": "^1.10.0",
|
|
36
36
|
"bcrypt": "^5.1.1",
|
|
37
37
|
"cors": "^2.8.5",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"log4js": "^6.9.1",
|
|
43
43
|
"mongodb": "^6.12.0",
|
|
44
44
|
"multer": "^1.4.5-lts.1",
|
|
45
|
+
"nodemailer": "^7.0.5",
|
|
45
46
|
"reflect-metadata": "^0.2.2",
|
|
46
47
|
"socket.io": "^4.8.1",
|
|
47
48
|
"systeminformation": "^5.25.11"
|