@tsed/socketio-testing 7.0.0-beta.1 → 7.0.0-beta.12
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/lib/cjs/index.js +1 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/services/SocketClientService.js +5 -5
- package/lib/cjs/services/SocketClientService.js.map +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/package.json +3 -0
- package/package.json +14 -10
- package/readme.md +82 -97
- package/tsconfig.compile.esm.json +1 -12
package/lib/cjs/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
|
|
4
|
+
tslib_1.__exportStar(require("./services/SocketClientService"), exports);
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,yEAA+C","sourcesContent":["export * from \"./services/SocketClientService\";\n"]}
|
|
@@ -29,15 +29,15 @@ let SocketClientService = class SocketClientService {
|
|
|
29
29
|
this.logger.debug("Socket.io clients closed...");
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
|
-
|
|
32
|
+
tslib_1.__decorate([
|
|
33
33
|
(0, di_1.Configuration)(),
|
|
34
|
-
|
|
34
|
+
tslib_1.__metadata("design:type", Object)
|
|
35
35
|
], SocketClientService.prototype, "settings", void 0);
|
|
36
|
-
|
|
36
|
+
tslib_1.__decorate([
|
|
37
37
|
(0, common_1.Inject)(),
|
|
38
|
-
|
|
38
|
+
tslib_1.__metadata("design:type", common_1.Logger)
|
|
39
39
|
], SocketClientService.prototype, "logger", void 0);
|
|
40
|
-
SocketClientService =
|
|
40
|
+
SocketClientService = tslib_1.__decorate([
|
|
41
41
|
(0, di_1.Injectable)()
|
|
42
42
|
], SocketClientService);
|
|
43
43
|
exports.SocketClientService = SocketClientService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SocketClientService.js","sourceRoot":"","sources":["../../../src/services/SocketClientService.ts"],"names":[],"mappings":";;;;AAAA,yCAAuD;AACvD,iCAAmD;AACnD,uDAA4C;AAG5C,IAAa,mBAAmB,GAAhC,MAAa,mBAAmB;IAAhC;QAOU,YAAO,GAAwB,IAAI,GAAG,EAAE,CAAC;IA4BnD,CAAC;IA1BC,KAAK,CAAC,GAAG,CAAC,YAAoB,GAAG,EAAE,IAAa;QAC9C,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YAC/B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAE,CAAC;SACrC;QAED,MAAM,EAAC,OAAO,EAAE,IAAI,EAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;QACpD,MAAM,GAAG,GAAG,UAAU,OAAO,IAAI,IAAI,GAAG,SAAS,EAAE,CAAC;QAEpD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,EAAE,GAAG,CAAC,CAAC;QACnD,MAAM,MAAM,GAAG,IAAA,qBAAE,EAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,EAAC,IAAI,EAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAElD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAEpC,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC5B,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,OAAc,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;QAEnD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,UAAU;QACR,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACnD,CAAC;CACF,CAAA;AAjCC;IADC,IAAA,kBAAa,GAAE;;qDACgB;AAGhC;IADC,IAAA,eAAM,GAAE;
|
|
1
|
+
{"version":3,"file":"SocketClientService.js","sourceRoot":"","sources":["../../../src/services/SocketClientService.ts"],"names":[],"mappings":";;;;AAAA,yCAAuD;AACvD,iCAAmD;AACnD,uDAA4C;AAG5C,IAAa,mBAAmB,GAAhC,MAAa,mBAAmB;IAAhC;QAOU,YAAO,GAAwB,IAAI,GAAG,EAAE,CAAC;IA4BnD,CAAC;IA1BC,KAAK,CAAC,GAAG,CAAC,YAAoB,GAAG,EAAE,IAAa;QAC9C,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YAC/B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAE,CAAC;SACrC;QAED,MAAM,EAAC,OAAO,EAAE,IAAI,EAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;QACpD,MAAM,GAAG,GAAG,UAAU,OAAO,IAAI,IAAI,GAAG,SAAS,EAAE,CAAC;QAEpD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,EAAE,GAAG,CAAC,CAAC;QACnD,MAAM,MAAM,GAAG,IAAA,qBAAE,EAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,EAAC,IAAI,EAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAElD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAEpC,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC5B,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,OAAc,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;QAEnD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,UAAU;QACR,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACnD,CAAC;CACF,CAAA;AAjCC;IADC,IAAA,kBAAa,GAAE;;qDACgB;AAGhC;IADC,IAAA,eAAM,GAAE;sCACO,eAAM;mDAAC;AALZ,mBAAmB;IAD/B,IAAA,eAAU,GAAE;GACA,mBAAmB,CAmC/B;AAnCY,kDAAmB","sourcesContent":["import {Inject, Logger, OnDestroy} from \"@tsed/common\";\nimport {Configuration, Injectable} from \"@tsed/di\";\nimport {io, Socket} from \"socket.io-client\";\n\n@Injectable()\nexport class SocketClientService implements OnDestroy {\n @Configuration()\n private settings: Configuration;\n\n @Inject()\n private logger: Logger;\n\n private clients: Map<string, Socket> = new Map();\n\n async get(namespace: string = \"/\", path?: string): Promise<Socket> {\n if (this.clients.has(namespace)) {\n return this.clients.get(namespace)!;\n }\n\n const {address, port} = this.settings.getHttpPort();\n const uri = `http://${address}:${port}${namespace}`;\n\n this.logger.info(\"Bind Socket.io client on:\", uri);\n const client = io(uri, path ? {path} : undefined);\n\n this.clients.set(namespace, client);\n\n await new Promise((resolve) => {\n client.on(\"connect\", resolve as any);\n });\n\n this.logger.debug(\"Socket.io client connected...\");\n\n return client;\n }\n\n $onDestroy() {\n this.clients.forEach((client) => client.close());\n this.logger.debug(\"Socket.io clients closed...\");\n }\n}\n"]}
|
package/lib/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./services/SocketClientService";
|
|
1
|
+
export * from "./services/SocketClientService.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/socketio-testing",
|
|
3
|
-
"version": "7.0.0-beta.
|
|
3
|
+
"version": "7.0.0-beta.12",
|
|
4
4
|
"description": "Socket.io testing package for Ts.ED framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
7
|
"main": "./lib/cjs/index.js",
|
|
8
|
+
"module": "./lib/esm/index.js",
|
|
8
9
|
"typings": "./lib/types/index.d.ts",
|
|
9
10
|
"exports": {
|
|
10
11
|
"types": "./lib/types/index.d.ts",
|
|
@@ -19,25 +20,28 @@
|
|
|
19
20
|
"start": "ts-node -r tsconfig-paths/register test/app/index.ts"
|
|
20
21
|
},
|
|
21
22
|
"dependencies": {
|
|
22
|
-
"tslib": "2.
|
|
23
|
+
"tslib": "2.3.1"
|
|
23
24
|
},
|
|
24
25
|
"devDependencies": {
|
|
25
|
-
"@tsed/common": "7.0.0-beta.
|
|
26
|
-
"@tsed/di": "7.0.0-beta.
|
|
26
|
+
"@tsed/common": "7.0.0-beta.12",
|
|
27
|
+
"@tsed/di": "7.0.0-beta.12",
|
|
27
28
|
"socket.io-client": "^4.1.2"
|
|
28
29
|
},
|
|
29
30
|
"peerDependencies": {
|
|
30
|
-
"@tsed/common": "^7.0.0-beta.
|
|
31
|
-
"@tsed/core": "^7.0.0-beta.
|
|
32
|
-
"@tsed/di": "^7.0.0-beta.
|
|
33
|
-
"@tsed/socketio": "^7.0.0-beta.
|
|
31
|
+
"@tsed/common": "^7.0.0-beta.12",
|
|
32
|
+
"@tsed/core": "^7.0.0-beta.12",
|
|
33
|
+
"@tsed/di": "^7.0.0-beta.12",
|
|
34
|
+
"@tsed/socketio": "^7.0.0-beta.12",
|
|
34
35
|
"socket.io-client": "^4.0.1"
|
|
35
36
|
},
|
|
36
37
|
"repository": "https://github.com/tsedio/tsed",
|
|
37
38
|
"bugs": {
|
|
38
39
|
"url": "https://github.com/tsedio/tsed/issues"
|
|
39
40
|
},
|
|
40
|
-
"homepage": "https://github.com/tsedio/tsed/tree/
|
|
41
|
+
"homepage": "https://github.com/tsedio/tsed/tree/beta/packages/third-parties/socketio-testing",
|
|
41
42
|
"author": "Romain Lenzotti",
|
|
42
|
-
"license": "MIT"
|
|
43
|
+
"license": "MIT",
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"tag": "beta"
|
|
46
|
+
}
|
|
43
47
|
}
|
package/readme.md
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
[](https://badge.fury.io/js/%40tsed%2Fcommon)
|
|
12
12
|
[](https://github.com/semantic-release/semantic-release)
|
|
13
13
|
[](https://github.com/prettier/prettier)
|
|
14
|
-
[](https://github.com/sponsors/romakita)
|
|
15
|
+
[](https://opencollective.com/tsed)
|
|
15
16
|
|
|
16
17
|
</div>
|
|
17
18
|
|
|
@@ -44,24 +45,20 @@ Then add the following configuration in your Server:
|
|
|
44
45
|
import {Configuration} from "@tsed/common";
|
|
45
46
|
import "@tsed/socketio"; // import socketio Ts.ED module
|
|
46
47
|
import {resolve} from "path";
|
|
47
|
-
const rootDir = resolve(__dirname)
|
|
48
48
|
|
|
49
49
|
@Configuration({
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
50
|
+
socketIO: {
|
|
51
|
+
// ... see configuration
|
|
52
|
+
}
|
|
54
53
|
})
|
|
55
|
-
export class Server {
|
|
56
|
-
|
|
57
|
-
}
|
|
54
|
+
export class Server {}
|
|
58
55
|
```
|
|
59
56
|
|
|
60
57
|
## Socket Service
|
|
61
58
|
|
|
62
59
|
> Socket.IO allows you to “namespace” your sockets, which essentially means assigning different endpoints or paths.
|
|
63
|
-
This is a useful feature to minimize the number of resources (TCP connections) and at the same time separate concerns within your application
|
|
64
|
-
by introducing separation between communication channels. See [namespace documentation](https://socket.io/docs/rooms-and-namespaces/#).
|
|
60
|
+
> This is a useful feature to minimize the number of resources (TCP connections) and at the same time separate concerns within your application
|
|
61
|
+
> by introducing separation between communication channels. See [namespace documentation](https://socket.io/docs/rooms-and-namespaces/#).
|
|
65
62
|
|
|
66
63
|
All Socket service work under a namespace and you can create one Socket service per namespace.
|
|
67
64
|
|
|
@@ -73,31 +70,24 @@ import {SocketService, IO, Nsp, Socket, SocketSession} from "@tsed/socketio";
|
|
|
73
70
|
|
|
74
71
|
@SocketService("/my-namespace")
|
|
75
72
|
export class MySocketService {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Triggered when a client disconnects from the Namespace.
|
|
97
|
-
*/
|
|
98
|
-
$onDisconnect(@Socket socket: SocketIO.Socket) {
|
|
99
|
-
|
|
100
|
-
}
|
|
73
|
+
@Nsp nsp: SocketIO.Namespace;
|
|
74
|
+
|
|
75
|
+
@Nsp("/my-other-namespace")
|
|
76
|
+
nspOther: SocketIO.Namespace; // communication between two namespace
|
|
77
|
+
|
|
78
|
+
constructor(@IO private io: SocketIO.Server) {}
|
|
79
|
+
/**
|
|
80
|
+
* Triggered the namespace is created
|
|
81
|
+
*/
|
|
82
|
+
$onNamespaceInit(nsp: SocketIO.Namespace) {}
|
|
83
|
+
/**
|
|
84
|
+
* Triggered when a new client connects to the Namespace.
|
|
85
|
+
*/
|
|
86
|
+
$onConnection(@Socket socket: SocketIO.Socket, @SocketSession session: SocketSession) {}
|
|
87
|
+
/**
|
|
88
|
+
* Triggered when a client disconnects from the Namespace.
|
|
89
|
+
*/
|
|
90
|
+
$onDisconnect(@Socket socket: SocketIO.Socket) {}
|
|
101
91
|
}
|
|
102
92
|
```
|
|
103
93
|
|
|
@@ -111,13 +101,14 @@ import {SocketService, Nsp} from "@tsed/socketio";
|
|
|
111
101
|
|
|
112
102
|
@SocketService()
|
|
113
103
|
export class MySocketService {
|
|
114
|
-
|
|
104
|
+
@Nsp nsp: SocketIO.Namespace;
|
|
115
105
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
106
|
+
helloAll() {
|
|
107
|
+
this.nsp.emit("hi", "everyone!");
|
|
108
|
+
}
|
|
119
109
|
}
|
|
120
110
|
```
|
|
111
|
+
|
|
121
112
|
Then, you can inject your socket service into another Service, Controller, etc... as following:
|
|
122
113
|
|
|
123
114
|
```typescript
|
|
@@ -126,16 +117,13 @@ import {MySocketService} from "../services/MySocketService";
|
|
|
126
117
|
|
|
127
118
|
@Controller("/")
|
|
128
119
|
export class MyCtrl {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
this.mySocketService.helloAll();
|
|
137
|
-
return "is sent";
|
|
138
|
-
}
|
|
120
|
+
constructor(private mySocketService: MySocketService) {}
|
|
121
|
+
|
|
122
|
+
@Get("/allo")
|
|
123
|
+
allo() {
|
|
124
|
+
this.mySocketService.helloAll();
|
|
125
|
+
return "is sent";
|
|
126
|
+
}
|
|
139
127
|
}
|
|
140
128
|
```
|
|
141
129
|
|
|
@@ -148,10 +136,10 @@ import {SocketService, Input, Emit, Args, Socket, Nsp} from "@tsed/socketio";
|
|
|
148
136
|
|
|
149
137
|
@SocketService("/my-namespace")
|
|
150
138
|
export class MySocketService {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
139
|
+
@Input("eventName")
|
|
140
|
+
myMethod(@Args(0) userName: string, @Socket socket: SocketIO.Socket, @Nsp nsp: SocketIO.Namespace) {
|
|
141
|
+
console.log(userName);
|
|
142
|
+
}
|
|
155
143
|
}
|
|
156
144
|
```
|
|
157
145
|
|
|
@@ -172,13 +160,14 @@ import {SocketService, Input, Emit, Args, Socket, Nsp} from "@tsed/socketio";
|
|
|
172
160
|
|
|
173
161
|
@SocketService("/my-namespace")
|
|
174
162
|
export class MySocketService {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
163
|
+
@Input("eventName")
|
|
164
|
+
@Emit("responseEventName") // or Broadcast or BroadcastOthers
|
|
165
|
+
async myMethod(@Args(0) userName: string, @Socket socket: SocketIO.Socket) {
|
|
166
|
+
return "Message " + userName;
|
|
167
|
+
}
|
|
180
168
|
}
|
|
181
169
|
```
|
|
170
|
+
|
|
182
171
|
> The method accept a promise as returned value.
|
|
183
172
|
|
|
184
173
|
::: warning
|
|
@@ -194,17 +183,16 @@ import {SocketService, Input, Emit, Args, SocketSession} from "@tsed/socketio";
|
|
|
194
183
|
|
|
195
184
|
@SocketService("/my-namespace")
|
|
196
185
|
export class MySocketService {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
186
|
+
@Input("eventName")
|
|
187
|
+
@Emit("responseEventName") // or Broadcast or BroadcastOthers
|
|
188
|
+
async myMethod(@Args(0) userName: string, @SocketSession session: SocketSession) {
|
|
189
|
+
const user = session.get("user") || {};
|
|
190
|
+
user.name = userName;
|
|
200
191
|
|
|
201
|
-
|
|
202
|
-
user.name = userName;
|
|
192
|
+
session.set("user", user);
|
|
203
193
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
return user;
|
|
207
|
-
}
|
|
194
|
+
return user;
|
|
195
|
+
}
|
|
208
196
|
}
|
|
209
197
|
```
|
|
210
198
|
|
|
@@ -221,16 +209,16 @@ import {User} from "../models/User";
|
|
|
221
209
|
|
|
222
210
|
@SocketMiddleware()
|
|
223
211
|
export class UserConverterSocketMiddleware {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
}
|
|
212
|
+
async use(@Args() args: any[]) {
|
|
213
|
+
let [user] = args;
|
|
214
|
+
// update Arguments
|
|
215
|
+
user = deserialize(user, {type: User});
|
|
216
|
+
|
|
217
|
+
return [user];
|
|
218
|
+
}
|
|
232
219
|
}
|
|
233
220
|
```
|
|
221
|
+
|
|
234
222
|
> The user instance will be forwarded to the next middleware and to your decorated method.
|
|
235
223
|
|
|
236
224
|
You can also declare a middleware to handle an error with `@SocketMiddlewareError`.
|
|
@@ -241,10 +229,10 @@ import {SocketMiddlewareError, SocketErr, Socket} from "@tsed/socketio";
|
|
|
241
229
|
|
|
242
230
|
@SocketMiddlewareError()
|
|
243
231
|
export class ErrorHandlerSocketMiddleware {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
232
|
+
async use(@SocketErr err: any, @Socket socket: SocketIO.Socket) {
|
|
233
|
+
console.error(err);
|
|
234
|
+
socket.emit("error", {message: "An error has occured"});
|
|
235
|
+
}
|
|
248
236
|
}
|
|
249
237
|
```
|
|
250
238
|
|
|
@@ -260,7 +248,7 @@ The call sequences is the following for each event request:
|
|
|
260
248
|
- Middlewares attached with `@SocketUseBefore` on method,
|
|
261
249
|
- The method,
|
|
262
250
|
- Send response if the method is decorated with `@Emit`, `@Broadcast` or `@BroadcastOther`,
|
|
263
|
-
- Middlewares attached with `@SocketUseAfter` on method,
|
|
251
|
+
- Middlewares attached with `@SocketUseAfter` on method,
|
|
264
252
|
- Middlewares attached with `@SocketUseAfter` on class.
|
|
265
253
|
|
|
266
254
|
Middlewares chain use the `Promise` to run it. If one of this middlewares/method emit an error, the first middleware error will be called.
|
|
@@ -274,20 +262,18 @@ import {User} from "../models/User";
|
|
|
274
262
|
@SocketUseBefore(UserConverterSocketMiddleware) // global version
|
|
275
263
|
@SocketUseAfter(ErrorHandlerSocketMiddleware)
|
|
276
264
|
export class MySocketService {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
return user;
|
|
290
|
-
}
|
|
265
|
+
@Input("eventName")
|
|
266
|
+
@Emit("responseEventName") // or Broadcast or BroadcastOthers
|
|
267
|
+
@SocketUseBefore(UserConverterSocketMiddleware)
|
|
268
|
+
@SocketUseAfter(ErrorHandlerSocketMiddleware)
|
|
269
|
+
async myMethod(@Args(0) userName: User) {
|
|
270
|
+
const user = session.get("user") || {};
|
|
271
|
+
user.name = userName;
|
|
272
|
+
|
|
273
|
+
session.set("user", user);
|
|
274
|
+
|
|
275
|
+
return user;
|
|
276
|
+
}
|
|
291
277
|
}
|
|
292
278
|
```
|
|
293
279
|
|
|
@@ -296,18 +282,17 @@ export class MySocketService {
|
|
|
296
282
|
See our documentation https://tsed.io/#/api/index
|
|
297
283
|
|
|
298
284
|
## Contributors
|
|
285
|
+
|
|
299
286
|
Please read [contributing guidelines here](https://tsed.io/CONTRIBUTING.html)
|
|
300
287
|
|
|
301
288
|
<a href="https://github.com/tsedio/ts-express-decorators/graphs/contributors"><img src="https://opencollective.com/tsed/contributors.svg?width=890" /></a>
|
|
302
289
|
|
|
303
|
-
|
|
304
290
|
## Backers
|
|
305
291
|
|
|
306
292
|
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/tsed#backer)]
|
|
307
293
|
|
|
308
294
|
<a href="https://opencollective.com/tsed#backers" target="_blank"><img src="https://opencollective.com/tsed/tiers/backer.svg?width=890"></a>
|
|
309
295
|
|
|
310
|
-
|
|
311
296
|
## Sponsors
|
|
312
297
|
|
|
313
298
|
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/tsed#sponsor)]
|
|
@@ -8,16 +8,5 @@
|
|
|
8
8
|
"declaration": true,
|
|
9
9
|
"declarationDir": "./lib/types"
|
|
10
10
|
},
|
|
11
|
-
"exclude": [
|
|
12
|
-
"node_modules",
|
|
13
|
-
"test",
|
|
14
|
-
"lib",
|
|
15
|
-
"benchmark",
|
|
16
|
-
"coverage",
|
|
17
|
-
"spec",
|
|
18
|
-
"**/*.benchmark.ts",
|
|
19
|
-
"**/*.spec.ts",
|
|
20
|
-
"keys",
|
|
21
|
-
"jest.config.js"
|
|
22
|
-
]
|
|
11
|
+
"exclude": ["node_modules", "test", "lib", "benchmark", "coverage", "spec", "**/*.benchmark.ts", "**/*.spec.ts", "keys", "jest.config.js"]
|
|
23
12
|
}
|