@tsed/socketio 8.17.3 → 8.18.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.
Files changed (2) hide show
  1. package/package.json +11 -11
  2. package/readme.md +40 -15
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@tsed/socketio",
3
3
  "description": "Socket.io package for Ts.ED framework",
4
4
  "type": "module",
5
- "version": "8.17.3",
5
+ "version": "8.18.1",
6
6
  "keywords": [
7
7
  "tsed",
8
8
  "socket.io",
@@ -34,16 +34,16 @@
34
34
  "tslib": "2.7.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@tsed/barrels": "8.17.3",
38
- "@tsed/core": "8.17.3",
39
- "@tsed/di": "8.17.3",
40
- "@tsed/json-mapper": "8.17.3",
41
- "@tsed/openspec": "8.17.3",
42
- "@tsed/platform-http": "8.17.3",
43
- "@tsed/platform-middlewares": "8.17.3",
44
- "@tsed/schema": "8.17.3",
45
- "@tsed/socketio-testing": "8.17.3",
46
- "@tsed/typescript": "8.17.3",
37
+ "@tsed/barrels": "8.18.1",
38
+ "@tsed/core": "8.18.1",
39
+ "@tsed/di": "8.18.1",
40
+ "@tsed/json-mapper": "8.18.1",
41
+ "@tsed/openspec": "8.18.1",
42
+ "@tsed/platform-http": "8.18.1",
43
+ "@tsed/platform-middlewares": "8.18.1",
44
+ "@tsed/schema": "8.18.1",
45
+ "@tsed/socketio-testing": "8.18.1",
46
+ "@tsed/typescript": "8.18.1",
47
47
  "eslint": "9.12.0",
48
48
  "express": "^4.21.0",
49
49
  "socket.io": "4.8.0",
package/readme.md CHANGED
@@ -20,7 +20,7 @@
20
20
  <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
21
21
  <a href="https://tsed.dev/getting-started/">Getting started</a>
22
22
  <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
23
- <a href="https://slack.tsed.io">Slack</a>
23
+ <a href="https://slack.tsed.dev">Slack</a>
24
24
  <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
25
25
  <a href="https://twitter.com/TsED_io">Twitter</a>
26
26
  </div>
@@ -29,7 +29,8 @@
29
29
 
30
30
  A package of Ts.ED framework. See website: https://tsed.dev/tutorials/socket-io
31
31
 
32
- Socket.io enable real-time bidirectional event-based communication. It works on every platform, browser or device, focusing equally on reliability and speed.
32
+ Socket.io enable real-time bidirectional event-based communication. It works on every platform, browser or device,
33
+ focusing equally on reliability and speed.
33
34
 
34
35
  ## Installation
35
36
 
@@ -57,8 +58,10 @@ export class Server {}
57
58
  ## Socket Service
58
59
 
59
60
  > Socket.IO allows you to “namespace” your sockets, which essentially means assigning different endpoints or paths.
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/#).
61
+ > This is a useful feature to minimize the number of resources (TCP connections) and at the same time separate concerns
62
+ > within your application
63
+ > by introducing separation between communication channels.
64
+ > See [namespace documentation](https://socket.io/docs/rooms-and-namespaces/#).
62
65
 
63
66
  All Socket service work under a namespace and you can create one Socket service per namespace.
64
67
 
@@ -76,14 +79,17 @@ export class MySocketService {
76
79
  nspOther: SocketIO.Namespace; // communication between two namespace
77
80
 
78
81
  constructor(@IO private io: SocketIO.Server) {}
82
+
79
83
  /**
80
84
  * Triggered the namespace is created
81
85
  */
82
86
  $onNamespaceInit(nsp: SocketIO.Namespace) {}
87
+
83
88
  /**
84
89
  * Triggered when a new client connects to the Namespace.
85
90
  */
86
91
  $onConnection(@Socket socket: SocketIO.Socket, @SocketSession session: SocketSession) {}
92
+
87
93
  /**
88
94
  * Triggered when a client disconnects from the Namespace.
89
95
  */
@@ -91,7 +97,8 @@ export class MySocketService {
91
97
  }
92
98
  ```
93
99
 
94
- > @SocketService inherit from @Service decorator. That means, a SocketService can be injected to another Service, Controller or Middleware.
100
+ > @SocketService inherit from @Service decorator. That means, a SocketService can be injected to another Service,
101
+ > Controller or Middleware.
95
102
 
96
103
  Example:
97
104
 
@@ -172,7 +179,9 @@ export class MySocketService {
172
179
  > The method accept a promise as returned value.
173
180
 
174
181
  ::: warning
175
- Return value is only possible when the method is decorated by [@Emit](https://tsed.dev/api/socketio/emit.html), [@Broadcast](https://tsed.dev/api/socketio/broadcast.html) and [@BroadcastOthers](https://tsed.dev/api/socketio/broadcastothers.html).
182
+ Return value is only possible when the method is decorated
183
+ by [@Emit](https://tsed.dev/api/socketio/emit.html), [@Broadcast](https://tsed.dev/api/socketio/broadcast.html)
184
+ and [@BroadcastOthers](https://tsed.dev/api/socketio/broadcastothers.html).
176
185
  :::
177
186
 
178
187
  ### Socket Session
@@ -197,11 +206,15 @@ export class MySocketService {
197
206
  }
198
207
  ```
199
208
 
200
- The session represents an arbitrary object that facilitates the storage of session data, allowing the sharing of information between Socket.IO servers.
209
+ The session represents an arbitrary object that facilitates the storage of session data, allowing the sharing of
210
+ information between Socket.IO servers.
201
211
 
202
- In the event of an unexpected disconnection (i.e., when the socket is not manually disconnected using `socket.disconnect()`), the server will store the session of the socket. Upon reconnection, the server will make an attempt to restore the previous session.
212
+ In the event of an unexpected disconnection (i.e., when the socket is not manually disconnected using
213
+ `socket.disconnect()`), the server will store the session of the socket. Upon reconnection, the server will make an
214
+ attempt to restore the previous session.
203
215
 
204
- To enable this behavior, you need to configure the [Connection state recovery](https://socket.io/docs/v4/connection-state-recovery) as follows:
216
+ To enable this behavior, you need to configure
217
+ the [Connection state recovery](https://socket.io/docs/v4/connection-state-recovery) as follows:
205
218
 
206
219
  ```ts
207
220
  import {Configuration} from "@tsed/di";
@@ -222,7 +235,10 @@ import "@tsed/socketio";
222
235
  export class Server {}
223
236
  ```
224
237
 
225
- > By default, Ts.ED uses the built-in in-memory adapter for session management. However, for production environments, it is recommended to use [the persistent adapters](https://socket.io/docs/v4/connection-state-recovery#compatibility-with-existing-adapters) to enhance reliability.
238
+ > By default, Ts.ED uses the built-in in-memory adapter for session management. However, for production environments, it
239
+ > is recommended to
240
+ > use [the persistent adapters](https://socket.io/docs/v4/connection-state-recovery#compatibility-with-existing-adapters)
241
+ > to enhance reliability.
226
242
 
227
243
  ### Middlewares
228
244
 
@@ -279,7 +295,8 @@ The call sequences is the following for each event request:
279
295
  - Middlewares attached with `@SocketUseAfter` on method,
280
296
  - Middlewares attached with `@SocketUseAfter` on class.
281
297
 
282
- Middlewares chain use the `Promise` to run it. If one of this middlewares/method emit an error, the first middleware error will be called.
298
+ Middlewares chain use the `Promise` to run it. If one of this middlewares/method emit an error, the first middleware
299
+ error will be called.
283
300
 
284
301
  ```typescript
285
302
  import {SocketService, SocketUseAfter, SocketUseBefore, Emit, Input, Args, SocketSession} from "@tsed/socketio";
@@ -322,7 +339,8 @@ Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com
322
339
 
323
340
  ## Sponsors
324
341
 
325
- 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)]
342
+ Support this project by becoming a sponsor. Your logo will show up here with a link to your
343
+ website. [[Become a sponsor](https://opencollective.com/tsed#sponsor)]
326
344
 
327
345
  ## License
328
346
 
@@ -330,8 +348,15 @@ The MIT License (MIT)
330
348
 
331
349
  Copyright (c) 2016 - 2022 Romain Lenzotti
332
350
 
333
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
351
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
352
+ documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
353
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
354
+ persons to whom the Software is furnished to do so, subject to the following conditions:
334
355
 
335
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
356
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
357
+ Software.
336
358
 
337
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
359
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
360
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
361
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
362
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.