@roomkit/gateway 1.0.0

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.
Files changed (130) hide show
  1. package/README.md +93 -0
  2. package/dist/src/admin/admin.controller.d.ts +187 -0
  3. package/dist/src/admin/admin.controller.d.ts.map +1 -0
  4. package/dist/src/admin/admin.controller.js +187 -0
  5. package/dist/src/admin/admin.controller.js.map +1 -0
  6. package/dist/src/admin/admin.module.d.ts +3 -0
  7. package/dist/src/admin/admin.module.d.ts.map +1 -0
  8. package/dist/src/admin/admin.module.js +28 -0
  9. package/dist/src/admin/admin.module.js.map +1 -0
  10. package/dist/src/admin/admin.service.d.ts +196 -0
  11. package/dist/src/admin/admin.service.d.ts.map +1 -0
  12. package/dist/src/admin/admin.service.js +322 -0
  13. package/dist/src/admin/admin.service.js.map +1 -0
  14. package/dist/src/config/config.module.d.ts +3 -0
  15. package/dist/src/config/config.module.d.ts.map +1 -0
  16. package/dist/src/config/config.module.js +22 -0
  17. package/dist/src/config/config.module.js.map +1 -0
  18. package/dist/src/config/config.service.d.ts +19 -0
  19. package/dist/src/config/config.service.d.ts.map +1 -0
  20. package/dist/src/config/config.service.js +55 -0
  21. package/dist/src/config/config.service.js.map +1 -0
  22. package/dist/src/config/gateway.config.d.ts +64 -0
  23. package/dist/src/config/gateway.config.d.ts.map +1 -0
  24. package/dist/src/config/gateway.config.js +43 -0
  25. package/dist/src/config/gateway.config.js.map +1 -0
  26. package/dist/src/connection/connection.module.d.ts +3 -0
  27. package/dist/src/connection/connection.module.d.ts.map +1 -0
  28. package/dist/src/connection/connection.module.js +22 -0
  29. package/dist/src/connection/connection.module.js.map +1 -0
  30. package/dist/src/connection/connection.service.d.ts +93 -0
  31. package/dist/src/connection/connection.service.d.ts.map +1 -0
  32. package/dist/src/connection/connection.service.js +257 -0
  33. package/dist/src/connection/connection.service.js.map +1 -0
  34. package/dist/src/gateway.module.d.ts +8 -0
  35. package/dist/src/gateway.module.d.ts.map +1 -0
  36. package/dist/src/gateway.module.js +44 -0
  37. package/dist/src/gateway.module.js.map +1 -0
  38. package/dist/src/index.d.ts +38 -0
  39. package/dist/src/index.d.ts.map +1 -0
  40. package/dist/src/index.js +97 -0
  41. package/dist/src/index.js.map +1 -0
  42. package/dist/src/lifecycle/graceful-shutdown.service.d.ts +65 -0
  43. package/dist/src/lifecycle/graceful-shutdown.service.d.ts.map +1 -0
  44. package/dist/src/lifecycle/graceful-shutdown.service.js +187 -0
  45. package/dist/src/lifecycle/graceful-shutdown.service.js.map +1 -0
  46. package/dist/src/lifecycle/index.d.ts +2 -0
  47. package/dist/src/lifecycle/index.d.ts.map +1 -0
  48. package/dist/src/lifecycle/index.js +18 -0
  49. package/dist/src/lifecycle/index.js.map +1 -0
  50. package/dist/src/main.d.ts +2 -0
  51. package/dist/src/main.d.ts.map +1 -0
  52. package/dist/src/main.js +56 -0
  53. package/dist/src/main.js.map +1 -0
  54. package/dist/src/metrics/metrics.controller.d.ts +13 -0
  55. package/dist/src/metrics/metrics.controller.d.ts.map +1 -0
  56. package/dist/src/metrics/metrics.controller.js +42 -0
  57. package/dist/src/metrics/metrics.controller.js.map +1 -0
  58. package/dist/src/metrics/metrics.module.d.ts +3 -0
  59. package/dist/src/metrics/metrics.module.d.ts.map +1 -0
  60. package/dist/src/metrics/metrics.module.js +26 -0
  61. package/dist/src/metrics/metrics.module.js.map +1 -0
  62. package/dist/src/metrics/metrics.service.d.ts +81 -0
  63. package/dist/src/metrics/metrics.service.d.ts.map +1 -0
  64. package/dist/src/metrics/metrics.service.js +255 -0
  65. package/dist/src/metrics/metrics.service.js.map +1 -0
  66. package/dist/src/ratelimit/rate-limit.module.d.ts +3 -0
  67. package/dist/src/ratelimit/rate-limit.module.d.ts.map +1 -0
  68. package/dist/src/ratelimit/rate-limit.module.js +23 -0
  69. package/dist/src/ratelimit/rate-limit.module.js.map +1 -0
  70. package/dist/src/ratelimit/rate-limiter.service.d.ts +68 -0
  71. package/dist/src/ratelimit/rate-limiter.service.d.ts.map +1 -0
  72. package/dist/src/ratelimit/rate-limiter.service.js +201 -0
  73. package/dist/src/ratelimit/rate-limiter.service.js.map +1 -0
  74. package/dist/src/redis/redis.module.d.ts +3 -0
  75. package/dist/src/redis/redis.module.d.ts.map +1 -0
  76. package/dist/src/redis/redis.module.js +22 -0
  77. package/dist/src/redis/redis.module.js.map +1 -0
  78. package/dist/src/redis/redis.service.d.ts +68 -0
  79. package/dist/src/redis/redis.service.d.ts.map +1 -0
  80. package/dist/src/redis/redis.service.js +281 -0
  81. package/dist/src/redis/redis.service.js.map +1 -0
  82. package/dist/src/session/session.module.d.ts +3 -0
  83. package/dist/src/session/session.module.d.ts.map +1 -0
  84. package/dist/src/session/session.module.js +21 -0
  85. package/dist/src/session/session.module.js.map +1 -0
  86. package/dist/src/session/session.service.d.ts +64 -0
  87. package/dist/src/session/session.service.d.ts.map +1 -0
  88. package/dist/src/session/session.service.js +206 -0
  89. package/dist/src/session/session.service.js.map +1 -0
  90. package/dist/src/ws/message-router.service.d.ts +133 -0
  91. package/dist/src/ws/message-router.service.d.ts.map +1 -0
  92. package/dist/src/ws/message-router.service.js +715 -0
  93. package/dist/src/ws/message-router.service.js.map +1 -0
  94. package/dist/src/ws/response-handler.service.d.ts +53 -0
  95. package/dist/src/ws/response-handler.service.d.ts.map +1 -0
  96. package/dist/src/ws/response-handler.service.js +282 -0
  97. package/dist/src/ws/response-handler.service.js.map +1 -0
  98. package/dist/src/ws/ws.gateway.d.ts +46 -0
  99. package/dist/src/ws/ws.gateway.d.ts.map +1 -0
  100. package/dist/src/ws/ws.gateway.js +244 -0
  101. package/dist/src/ws/ws.gateway.js.map +1 -0
  102. package/dist/src/ws/ws.module.d.ts +8 -0
  103. package/dist/src/ws/ws.module.d.ts.map +1 -0
  104. package/dist/src/ws/ws.module.js +39 -0
  105. package/dist/src/ws/ws.module.js.map +1 -0
  106. package/dist/test/connection/connection.service.spec.d.ts +2 -0
  107. package/dist/test/connection/connection.service.spec.d.ts.map +1 -0
  108. package/dist/test/connection/connection.service.spec.js +204 -0
  109. package/dist/test/connection/connection.service.spec.js.map +1 -0
  110. package/dist/test/e2e/gateway-worker.e2e.spec.d.ts +2 -0
  111. package/dist/test/e2e/gateway-worker.e2e.spec.d.ts.map +1 -0
  112. package/dist/test/e2e/gateway-worker.e2e.spec.js +412 -0
  113. package/dist/test/e2e/gateway-worker.e2e.spec.js.map +1 -0
  114. package/dist/test/integration/admin-api.spec.d.ts +2 -0
  115. package/dist/test/integration/admin-api.spec.d.ts.map +1 -0
  116. package/dist/test/integration/admin-api.spec.js +218 -0
  117. package/dist/test/integration/admin-api.spec.js.map +1 -0
  118. package/dist/test/ratelimit/rate-limiter.service.spec.d.ts +2 -0
  119. package/dist/test/ratelimit/rate-limiter.service.spec.d.ts.map +1 -0
  120. package/dist/test/ratelimit/rate-limiter.service.spec.js +139 -0
  121. package/dist/test/ratelimit/rate-limiter.service.spec.js.map +1 -0
  122. package/dist/test/setup.d.ts +2 -0
  123. package/dist/test/setup.d.ts.map +1 -0
  124. package/dist/test/setup.js +56 -0
  125. package/dist/test/setup.js.map +1 -0
  126. package/dist/test/ws/message-router.service.spec.d.ts +2 -0
  127. package/dist/test/ws/message-router.service.spec.d.ts.map +1 -0
  128. package/dist/test/ws/message-router.service.spec.js +403 -0
  129. package/dist/test/ws/message-router.service.spec.js.map +1 -0
  130. package/package.json +78 -0
@@ -0,0 +1,244 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var WsGateway_1;
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.WsGateway = void 0;
17
+ const common_1 = require("@nestjs/common");
18
+ const ws_1 = require("ws");
19
+ const core_1 = require("@roomkit/core");
20
+ const config_service_1 = require("../config/config.service");
21
+ const connection_service_1 = require("../connection/connection.service");
22
+ const redis_service_1 = require("../redis/redis.service");
23
+ const message_router_service_1 = require("./message-router.service");
24
+ const rate_limiter_service_1 = require("../ratelimit/rate-limiter.service");
25
+ // 自定义WebSocket Gateway支持动态端口
26
+ let WsGateway = WsGateway_1 = class WsGateway {
27
+ wsPort;
28
+ configService;
29
+ connectionService;
30
+ redisService;
31
+ messageRouterService;
32
+ rateLimiterService;
33
+ logger = new common_1.Logger(WsGateway_1.name);
34
+ heartbeatTimer = null;
35
+ wsServer = null;
36
+ httpServer = null;
37
+ constructor(wsPort, configService, connectionService, redisService, messageRouterService, rateLimiterService) {
38
+ this.wsPort = wsPort;
39
+ this.configService = configService;
40
+ this.connectionService = connectionService;
41
+ this.redisService = redisService;
42
+ this.messageRouterService = messageRouterService;
43
+ this.rateLimiterService = rateLimiterService;
44
+ }
45
+ onModuleInit() {
46
+ this.startWebSocketServer();
47
+ this.startHeartbeatCheck();
48
+ this.logger.log('WebSocket Gateway initialized');
49
+ }
50
+ startWebSocketServer() {
51
+ // 创建WebSocket服务器
52
+ this.wsServer = new ws_1.WebSocketServer({
53
+ port: this.wsPort,
54
+ perMessageDeflate: false,
55
+ });
56
+ this.logger.log(`WebSocket server listening on port ${this.wsPort}`);
57
+ // 监听新连接
58
+ this.wsServer.on('connection', (ws) => {
59
+ this.handleConnection(ws);
60
+ });
61
+ // 监听错误
62
+ this.wsServer.on('error', (error) => {
63
+ this.logger.error('WebSocket server error:', error);
64
+ });
65
+ }
66
+ onModuleDestroy() {
67
+ if (this.heartbeatTimer) {
68
+ clearInterval(this.heartbeatTimer);
69
+ }
70
+ if (this.wsServer) {
71
+ this.wsServer.close(() => {
72
+ this.logger.log('WebSocket server closed');
73
+ });
74
+ }
75
+ }
76
+ /**
77
+ * 处理新连接
78
+ */
79
+ handleConnection(client) {
80
+ // 检查连接数限制
81
+ if (this.connectionService.getConnectionCount() >= this.configService.maxConnections) {
82
+ client.close(4029, 'SERVER_FULL');
83
+ return;
84
+ }
85
+ // 检查连接速率限制
86
+ if (!this.rateLimiterService.checkConnectionRate()) {
87
+ client.close(4029, 'RATE_LIMITED');
88
+ return;
89
+ }
90
+ // 创建连接
91
+ const connection = this.connectionService.createConnection(client);
92
+ this.logger.log(`New connection: ${connection.id}`);
93
+ // 设置消息处理
94
+ client.on('message', async (data) => {
95
+ this.logger.debug(`Received message from ${connection.id}`);
96
+ try {
97
+ const message = JSON.parse(data.toString());
98
+ const conn = this.connectionService.getConnection(connection.id);
99
+ if (conn) {
100
+ // 更新最后活动时间 - 收到任何消息都更新
101
+ this.connectionService.touch(connection.id);
102
+ // 处理测试用的ping消息
103
+ if (message.type === 'ping') {
104
+ const pongMessage = {
105
+ type: 'pong',
106
+ payload: message.payload,
107
+ timestamp: message.timestamp,
108
+ serverTime: Date.now()
109
+ };
110
+ client.send(JSON.stringify(pongMessage));
111
+ return;
112
+ }
113
+ // 处理标准格式的心跳消息
114
+ if (message.msgType === core_1.MessageType.HEARTBEAT) {
115
+ // 回复心跳确认
116
+ this.connectionService.sendByType(connection.id, core_1.MessageType.HEARTBEAT_ACK, {
117
+ timestamp: Date.now(),
118
+ });
119
+ return;
120
+ }
121
+ // 检查消息速率限制
122
+ const rateCheck = this.rateLimiterService.checkMessageRate(connection.id);
123
+ if (!rateCheck.allowed) {
124
+ this.connectionService.sendByType(connection.id, core_1.MessageType.ERROR, {
125
+ error: 'RATE_LIMITED',
126
+ retryAfter: rateCheck.retryAfter,
127
+ });
128
+ return;
129
+ }
130
+ // 处理标准消息格式
131
+ if (message.msgType) {
132
+ await this.messageRouterService.handleMessage(conn, message);
133
+ }
134
+ }
135
+ }
136
+ catch (error) {
137
+ this.logger.error('Failed to handle message', error);
138
+ }
139
+ });
140
+ // 处理错误
141
+ client.on('error', (error) => {
142
+ this.logger.error(`WebSocket error: ${error.message}`);
143
+ });
144
+ // 处理连接断开
145
+ client.on('close', async () => {
146
+ await this.handleDisconnect(client);
147
+ });
148
+ }
149
+ /**
150
+ * 处理连接断开
151
+ */
152
+ async handleDisconnect(client) {
153
+ // 找到对应的连接
154
+ const connections = this.connectionService.getAllConnections();
155
+ let connectionId;
156
+ for (const [id, conn] of connections) {
157
+ const socket = this.connectionService.getSocket(id);
158
+ if (socket === client) {
159
+ connectionId = id;
160
+ break;
161
+ }
162
+ }
163
+ if (connectionId) {
164
+ await this.cleanupConnection(connectionId);
165
+ }
166
+ }
167
+ /**
168
+ * 清理连接
169
+ *
170
+ * 多房间模式:通知用户所在的所有房间
171
+ */
172
+ async cleanupConnection(connectionId) {
173
+ const connection = this.connectionService.getConnection(connectionId);
174
+ if (connection) {
175
+ // 如果用户在房间中,通知所有房间的 Worker
176
+ if (connection.rooms.size > 0 && connection.userId) {
177
+ // 并行通知所有房间
178
+ const notifyPromises = [...connection.rooms].map(async (roomId) => {
179
+ const workerId = await this.redisService.client.get(core_1.RedisKeys.roomWorker(roomId));
180
+ if (workerId) {
181
+ const message = {
182
+ type: 'client-disconnect',
183
+ gatewayId: this.configService.gatewayId,
184
+ connectionId,
185
+ userId: connection.userId,
186
+ roomId,
187
+ timestamp: Date.now(),
188
+ };
189
+ await this.redisService.publish(core_1.RedisChannels.rpcWorker(workerId), message);
190
+ this.logger.debug(`Notified room ${roomId} about disconnect of ${connection.userId}`);
191
+ }
192
+ });
193
+ await Promise.all(notifyPromises);
194
+ }
195
+ // 清理限流计数器
196
+ this.rateLimiterService.removeConnection(connectionId);
197
+ // 移除连接
198
+ this.connectionService.removeConnection(connectionId, 'disconnected');
199
+ }
200
+ }
201
+ /**
202
+ * 启动心跳检查
203
+ */
204
+ startHeartbeatCheck() {
205
+ this.heartbeatTimer = setInterval(async () => {
206
+ // 检查心跳超时
207
+ const timedOut = this.connectionService.checkTimeouts(this.configService.heartbeatTimeout);
208
+ for (const connectionId of timedOut) {
209
+ this.logger.log(`Connection timeout: ${connectionId}`);
210
+ await this.cleanupConnection(connectionId);
211
+ }
212
+ // 检查空闲连接(认证后但未加入任何房间)
213
+ const idleTimeout = this.configService.idleConnectionTimeout;
214
+ if (idleTimeout > 0) {
215
+ const idle = this.connectionService.checkIdleConnections(idleTimeout);
216
+ for (const connectionId of idle) {
217
+ this.logger.log(`Idle connection cleanup: ${connectionId}`);
218
+ // 发送空闲断开通知
219
+ this.connectionService.sendByType(connectionId, core_1.MessageType.KICK_NOTIFY, {
220
+ reason: 'IDLE_TIMEOUT',
221
+ message: 'Connection closed due to inactivity',
222
+ });
223
+ await this.cleanupConnection(connectionId);
224
+ }
225
+ }
226
+ }, this.configService.heartbeatInterval);
227
+ }
228
+ /**
229
+ * 获取所有连接(用于调试)
230
+ */
231
+ getAllConnections() {
232
+ return this.connectionService.getAllConnections();
233
+ }
234
+ };
235
+ exports.WsGateway = WsGateway;
236
+ exports.WsGateway = WsGateway = WsGateway_1 = __decorate([
237
+ __param(0, (0, common_1.Inject)('WS_PORT')),
238
+ __metadata("design:paramtypes", [Number, config_service_1.ConfigService,
239
+ connection_service_1.ConnectionService,
240
+ redis_service_1.RedisService,
241
+ message_router_service_1.MessageRouterService,
242
+ rate_limiter_service_1.RateLimiterService])
243
+ ], WsGateway);
244
+ //# sourceMappingURL=ws.gateway.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ws.gateway.js","sourceRoot":"","sources":["../../../src/ws/ws.gateway.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA+E;AAC/E,2BAAgD;AAChD,wCAAqF;AAC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,iBAAiB,EAAE,CAAC;IACpD,CAAC;CACF,CAAA;AA3OY,8BAAS;oBAAT,SAAS;IAOjB,WAAA,IAAA,eAAM,EAAC,SAAS,CAAC,CAAA;6CACc,8BAAa;QACT,sCAAiB;QACtB,4BAAY;QACJ,6CAAoB;QACtB,yCAAkB;GAZ9C,SAAS,CA2OrB"}
@@ -0,0 +1,8 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+ export interface WsModuleOptions {
3
+ port?: number;
4
+ }
5
+ export declare class WsGatewayModule {
6
+ static forRoot(options?: WsModuleOptions): DynamicModule;
7
+ }
8
+ //# sourceMappingURL=ws.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ws.module.d.ts","sourceRoot":"","sources":["../../../src/ws/ws.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAOvD,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,qBACa,eAAe;IAC1B,MAAM,CAAC,OAAO,CAAC,OAAO,GAAE,eAAoB,GAAG,aAAa;CAgB7D"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var WsGatewayModule_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.WsGatewayModule = void 0;
11
+ const common_1 = require("@nestjs/common");
12
+ const ws_gateway_1 = require("./ws.gateway");
13
+ const message_router_service_1 = require("./message-router.service");
14
+ const response_handler_service_1 = require("./response-handler.service");
15
+ const rate_limiter_service_1 = require("../ratelimit/rate-limiter.service");
16
+ const session_module_1 = require("../session/session.module");
17
+ let WsGatewayModule = WsGatewayModule_1 = class WsGatewayModule {
18
+ static forRoot(options = {}) {
19
+ return {
20
+ module: WsGatewayModule_1,
21
+ imports: [session_module_1.SessionModule],
22
+ providers: [
23
+ {
24
+ provide: 'WS_PORT',
25
+ useValue: options.port || 18080,
26
+ },
27
+ ws_gateway_1.WsGateway,
28
+ message_router_service_1.MessageRouterService,
29
+ response_handler_service_1.ResponseHandlerService,
30
+ rate_limiter_service_1.RateLimiterService
31
+ ],
32
+ };
33
+ }
34
+ };
35
+ exports.WsGatewayModule = WsGatewayModule;
36
+ exports.WsGatewayModule = WsGatewayModule = WsGatewayModule_1 = __decorate([
37
+ (0, common_1.Module)({})
38
+ ], WsGatewayModule);
39
+ //# sourceMappingURL=ws.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ws.module.js","sourceRoot":"","sources":["../../../src/ws/ws.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAuD;AACvD,6CAAyC;AACzC,qEAAgE;AAChE,yEAAoE;AACpE,4EAAuE;AACvE,8DAA0D;AAOnD,IAAM,eAAe,uBAArB,MAAM,eAAe;IAC1B,MAAM,CAAC,OAAO,CAAC,UAA2B,EAAE;QAC1C,OAAO;YACL,MAAM,EAAE,iBAAe;YACvB,OAAO,EAAE,CAAC,8BAAa,CAAC;YACxB,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,SAAS;oBAClB,QAAQ,EAAE,OAAO,CAAC,IAAI,IAAI,KAAK;iBAChC;gBACD,sBAAS;gBACT,6CAAoB;gBACpB,iDAAsB;gBACtB,yCAAkB;aACnB;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAjBY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,eAAe,CAiB3B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=connection.service.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.service.spec.d.ts","sourceRoot":"","sources":["../../../test/connection/connection.service.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,204 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /// <reference types="jest" />
4
+ const connection_service_1 = require("../../src/connection/connection.service");
5
+ const ws_1 = require("ws");
6
+ describe('ConnectionService', () => {
7
+ let service;
8
+ let mockSocket;
9
+ beforeEach(() => {
10
+ service = new connection_service_1.ConnectionService();
11
+ // 创建模拟的 WebSocket
12
+ mockSocket = {
13
+ readyState: ws_1.WebSocket.OPEN,
14
+ send: jest.fn(),
15
+ close: jest.fn(),
16
+ on: jest.fn(),
17
+ };
18
+ });
19
+ afterEach(() => {
20
+ jest.clearAllMocks();
21
+ });
22
+ describe('createConnection', () => {
23
+ it('should create a new connection with unique ID', () => {
24
+ const connection = service.createConnection(mockSocket);
25
+ expect(connection).toBeDefined();
26
+ expect(connection.id).toBeDefined();
27
+ expect(connection.status).toBe('connected');
28
+ expect(connection.lastActivity).toBeLessThanOrEqual(Date.now());
29
+ expect(connection.createdAt).toBeLessThanOrEqual(Date.now());
30
+ });
31
+ it('should store the connection and socket', () => {
32
+ const connection = service.createConnection(mockSocket);
33
+ expect(service.getConnection(connection.id)).toBe(connection);
34
+ expect(service.getSocket(connection.id)).toBe(mockSocket);
35
+ });
36
+ it('should create unique IDs for multiple connections', () => {
37
+ const conn1 = service.createConnection(mockSocket);
38
+ const conn2 = service.createConnection(mockSocket);
39
+ expect(conn1.id).not.toBe(conn2.id);
40
+ });
41
+ it('should increment connection count', () => {
42
+ expect(service.getConnectionCount()).toBe(0);
43
+ service.createConnection(mockSocket);
44
+ expect(service.getConnectionCount()).toBe(1);
45
+ service.createConnection(mockSocket);
46
+ expect(service.getConnectionCount()).toBe(2);
47
+ });
48
+ });
49
+ describe('getConnection', () => {
50
+ it('should return connection by ID', () => {
51
+ const connection = service.createConnection(mockSocket);
52
+ const retrieved = service.getConnection(connection.id);
53
+ expect(retrieved).toBe(connection);
54
+ });
55
+ it('should return undefined for non-existent ID', () => {
56
+ const result = service.getConnection('non-existent-id');
57
+ expect(result).toBeUndefined();
58
+ });
59
+ });
60
+ describe('updateStatus', () => {
61
+ it('should update connection status', () => {
62
+ const connection = service.createConnection(mockSocket);
63
+ const oldActivity = connection.lastActivity;
64
+ // 模拟时间流逝
65
+ connection.lastActivity -= 10;
66
+ service.updateStatus(connection.id, 'identified');
67
+ expect(connection.status).toBe('identified');
68
+ expect(connection.lastActivity).toBeGreaterThanOrEqual(oldActivity - 10);
69
+ });
70
+ it('should do nothing for non-existent connection', () => {
71
+ // 不应抛出错误
72
+ expect(() => {
73
+ service.updateStatus('non-existent', 'identified');
74
+ }).not.toThrow();
75
+ });
76
+ });
77
+ describe('setUserId', () => {
78
+ it('should set userId on connection', () => {
79
+ const connection = service.createConnection(mockSocket);
80
+ service.setUserId(connection.id, 'user-123');
81
+ expect(connection.userId).toBe('user-123');
82
+ });
83
+ it('should create user-to-connection mapping', () => {
84
+ const connection = service.createConnection(mockSocket);
85
+ service.setUserId(connection.id, 'user-123');
86
+ expect(service.getConnectionIdByUserId('user-123')).toBe(connection.id);
87
+ });
88
+ });
89
+ describe('setRoom', () => {
90
+ it('should set room and update status to in-room', () => {
91
+ const connection = service.createConnection(mockSocket);
92
+ connection.status = 'identified';
93
+ service.setRoom(connection.id, 'room-abc');
94
+ expect(connection.currentRoom).toBe('room-abc');
95
+ expect(connection.status).toBe('in-room');
96
+ });
97
+ it('should clear room and update status to identified', () => {
98
+ const connection = service.createConnection(mockSocket);
99
+ connection.status = 'in-room';
100
+ connection.currentRoom = 'room-abc';
101
+ service.setRoom(connection.id, undefined);
102
+ expect(connection.currentRoom).toBeUndefined();
103
+ expect(connection.status).toBe('identified');
104
+ });
105
+ });
106
+ describe('send', () => {
107
+ it('should send JSON message to socket', () => {
108
+ const connection = service.createConnection(mockSocket);
109
+ const result = service.send(connection.id, 1001, { test: 'data' });
110
+ expect(result).toBe(true);
111
+ expect(mockSocket.send).toHaveBeenCalledWith(JSON.stringify({ msgId: 1001, payload: { test: 'data' } }));
112
+ });
113
+ it('should return false for non-existent connection', () => {
114
+ const result = service.send('non-existent', 1001, {});
115
+ expect(result).toBe(false);
116
+ });
117
+ it('should return false when socket is not open', () => {
118
+ const closedSocket = {
119
+ ...mockSocket,
120
+ readyState: ws_1.WebSocket.CLOSED,
121
+ };
122
+ const connection = service.createConnection(closedSocket);
123
+ const result = service.send(connection.id, 1001, {});
124
+ expect(result).toBe(false);
125
+ });
126
+ });
127
+ describe('removeConnection', () => {
128
+ it('should remove connection and socket', () => {
129
+ const connection = service.createConnection(mockSocket);
130
+ const connId = connection.id;
131
+ service.removeConnection(connId, 'test-reason');
132
+ expect(service.getConnection(connId)).toBeUndefined();
133
+ expect(service.getSocket(connId)).toBeUndefined();
134
+ expect(mockSocket.close).toHaveBeenCalledWith(1000, 'test-reason');
135
+ });
136
+ it('should remove user-to-connection mapping', () => {
137
+ const connection = service.createConnection(mockSocket);
138
+ service.setUserId(connection.id, 'user-123');
139
+ service.removeConnection(connection.id);
140
+ expect(service.getConnectionIdByUserId('user-123')).toBeUndefined();
141
+ });
142
+ it('should decrement connection count', () => {
143
+ const conn1 = service.createConnection(mockSocket);
144
+ service.createConnection(mockSocket);
145
+ expect(service.getConnectionCount()).toBe(2);
146
+ service.removeConnection(conn1.id);
147
+ expect(service.getConnectionCount()).toBe(1);
148
+ });
149
+ });
150
+ describe('touch', () => {
151
+ it('should update lastActivity timestamp', () => {
152
+ const connection = service.createConnection(mockSocket);
153
+ const originalTime = connection.lastActivity;
154
+ // 模拟时间流逝
155
+ connection.lastActivity = originalTime - 1000;
156
+ service.touch(connection.id);
157
+ expect(connection.lastActivity).toBeGreaterThan(originalTime - 1000);
158
+ });
159
+ });
160
+ describe('getAuthenticatedCount', () => {
161
+ it('should count only authenticated connections', () => {
162
+ const conn1 = service.createConnection(mockSocket);
163
+ const conn2 = service.createConnection(mockSocket);
164
+ const conn3 = service.createConnection(mockSocket);
165
+ conn1.status = 'connected';
166
+ conn2.status = 'identified';
167
+ conn3.status = 'in-room';
168
+ expect(service.getAuthenticatedCount()).toBe(2);
169
+ });
170
+ it('should return 0 when no authenticated connections', () => {
171
+ service.createConnection(mockSocket);
172
+ expect(service.getAuthenticatedCount()).toBe(0);
173
+ });
174
+ });
175
+ describe('checkTimeouts', () => {
176
+ it('should return IDs of timed out connections', () => {
177
+ const conn1 = service.createConnection(mockSocket);
178
+ const conn2 = service.createConnection(mockSocket);
179
+ // 模拟 conn1 超时
180
+ conn1.lastActivity = Date.now() - 60000;
181
+ // conn2 保持活跃
182
+ conn2.lastActivity = Date.now();
183
+ const timedOut = service.checkTimeouts(30000);
184
+ expect(timedOut).toContain(conn1.id);
185
+ expect(timedOut).not.toContain(conn2.id);
186
+ });
187
+ it('should return empty array when no timeouts', () => {
188
+ service.createConnection(mockSocket);
189
+ const timedOut = service.checkTimeouts(60000);
190
+ expect(timedOut).toHaveLength(0);
191
+ });
192
+ });
193
+ describe('getAllConnections', () => {
194
+ it('should return all connections as Map', () => {
195
+ const conn1 = service.createConnection(mockSocket);
196
+ const conn2 = service.createConnection(mockSocket);
197
+ const all = service.getAllConnections();
198
+ expect(all.size).toBe(2);
199
+ expect(all.get(conn1.id)).toBe(conn1);
200
+ expect(all.get(conn2.id)).toBe(conn2);
201
+ });
202
+ });
203
+ });
204
+ //# sourceMappingURL=connection.service.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.service.spec.js","sourceRoot":"","sources":["../../../test/connection/connection.service.spec.ts"],"names":[],"mappings":";;AAAA,8BAA8B;AAC9B,gFAA4E;AAC5E,2BAA+B;AAE/B,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,IAAI,OAA0B,CAAC;IAC/B,IAAI,UAAkC,CAAC;IAEvC,UAAU,CAAC,GAAG,EAAE;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AAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;YACnD,MAAM,KAAK,GAAG,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;YAEnD,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;YAExC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACzB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACtC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=gateway-worker.e2e.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gateway-worker.e2e.spec.d.ts","sourceRoot":"","sources":["../../../test/e2e/gateway-worker.e2e.spec.ts"],"names":[],"mappings":""}