@eleven-am/pondsocket-nest 0.0.49 → 0.0.51
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/package.json +2 -2
- package/services/pondSocket.js +14 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eleven-am/pondsocket-nest",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.51",
|
|
4
4
|
"description": "PondSocket is a fast simple socket server",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"socket",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@nestjs/common": "^10.3.7",
|
|
36
36
|
"@nestjs/core": "^10.3.7",
|
|
37
37
|
"@types/jest": "^29.5.12",
|
|
38
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "^7.5.0",
|
|
39
39
|
"eslint-plugin-file-progress": "^1.3.0",
|
|
40
40
|
"eslint-plugin-import": "^2.29.1",
|
|
41
41
|
"jest": "^29.7.0",
|
package/services/pondSocket.js
CHANGED
|
@@ -35,10 +35,7 @@ class PondSocketService {
|
|
|
35
35
|
this.externalGuards = externalGuards;
|
|
36
36
|
this.logger = new common_1.Logger(PondSocketService.name);
|
|
37
37
|
const httpAdapter = this.adapterHost.httpAdapter;
|
|
38
|
-
|
|
39
|
-
const socket = yield this.init(httpAdapter);
|
|
40
|
-
return socket.listen(...args);
|
|
41
|
-
});
|
|
38
|
+
void this.init(httpAdapter);
|
|
42
39
|
}
|
|
43
40
|
init(httpAdapter) {
|
|
44
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -49,7 +46,7 @@ class PondSocketService {
|
|
|
49
46
|
groupedInstances.forEach((groupedInstance) => {
|
|
50
47
|
this.manageEndpoint(socket, groupedInstance);
|
|
51
48
|
});
|
|
52
|
-
|
|
49
|
+
httpAdapter.listen = (...args) => socket.listen(...args);
|
|
53
50
|
});
|
|
54
51
|
}
|
|
55
52
|
manageEndpoint(socket, groupedInstance) {
|
|
@@ -62,9 +59,10 @@ class PondSocketService {
|
|
|
62
59
|
return;
|
|
63
60
|
}
|
|
64
61
|
setGuards(this.externalGuards);
|
|
62
|
+
const { get } = (0, connection_1.manageConnection)(instance);
|
|
63
|
+
const channels = [...new Set([...groupedInstance.channels.map((channel) => channel)])];
|
|
64
|
+
const [handler] = get();
|
|
65
65
|
const endpoint = socket.createEndpoint(metadata, (request, response) => __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
const { get } = (0, connection_1.manageConnection)(instance);
|
|
67
|
-
const [handler] = get();
|
|
68
66
|
if (handler) {
|
|
69
67
|
yield handler.value(instance, this.moduleRef, request, response);
|
|
70
68
|
}
|
|
@@ -73,11 +71,11 @@ class PondSocketService {
|
|
|
73
71
|
}
|
|
74
72
|
}));
|
|
75
73
|
this.logger.log(`Mapped {${metadata}} endpoint`);
|
|
74
|
+
if (handler) {
|
|
75
|
+
this.logger.log(`Mapped {${metadata}} connection handler`);
|
|
76
|
+
}
|
|
76
77
|
setEndpoint(endpoint);
|
|
77
|
-
|
|
78
|
-
channels.forEach((channel) => {
|
|
79
|
-
this.manageChannel(channel, endpoint, metadata);
|
|
80
|
-
});
|
|
78
|
+
channels.forEach((channel) => this.manageChannel(channel, endpoint, metadata));
|
|
81
79
|
}
|
|
82
80
|
manageChannel(channel, endpoint, endpointPath) {
|
|
83
81
|
const instance = channel.instance;
|
|
@@ -88,10 +86,10 @@ class PondSocketService {
|
|
|
88
86
|
}
|
|
89
87
|
const { set: setGuards } = (0, guards_1.manageGuards)(constructor);
|
|
90
88
|
const { set: setChannel } = (0, channelInstance_1.manageChannelInstance)(instance);
|
|
89
|
+
const { get } = (0, join_1.manageJoin)(instance);
|
|
90
|
+
const [handler] = get();
|
|
91
91
|
setGuards(this.externalGuards);
|
|
92
92
|
const channelInstance = endpoint.createChannel(path, (request, response) => __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
const { get } = (0, join_1.manageJoin)(instance);
|
|
94
|
-
const [handler] = get();
|
|
95
93
|
if (handler) {
|
|
96
94
|
yield handler.value(instance, this.moduleRef, request, response);
|
|
97
95
|
}
|
|
@@ -100,6 +98,9 @@ class PondSocketService {
|
|
|
100
98
|
}
|
|
101
99
|
}));
|
|
102
100
|
this.logger.log(`Mapped {${endpointPath}:${path}} channel`);
|
|
101
|
+
if (handler) {
|
|
102
|
+
this.logger.log(`Mapped {${endpointPath}:${path}} join handler`);
|
|
103
|
+
}
|
|
103
104
|
setChannel(channelInstance);
|
|
104
105
|
const { get: getEventHandlers } = (0, event_1.manageEvent)(instance);
|
|
105
106
|
const { get: getLeaveHandlers } = (0, leave_1.manageLeave)(instance);
|