@tsed/socketio 7.32.0 → 7.33.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.
- package/jest.config.js +3 -3
- package/lib/cjs/class/SocketHandlersBuilder.js +4 -2
- package/lib/cjs/class/SocketHandlersBuilder.js.map +1 -1
- package/lib/cjs/decorators/reason.js +34 -0
- package/lib/cjs/decorators/reason.js.map +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/interfaces/SocketFilters.js +1 -0
- package/lib/cjs/interfaces/SocketFilters.js.map +1 -1
- package/lib/cjs/services/SocketIOService.js +2 -2
- package/lib/cjs/services/SocketIOService.js.map +1 -1
- package/lib/esm/class/SocketHandlersBuilder.js +4 -2
- package/lib/esm/class/SocketHandlersBuilder.js.map +1 -1
- package/lib/esm/decorators/reason.js +30 -0
- package/lib/esm/decorators/reason.js.map +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/interfaces/SocketFilters.js +1 -0
- package/lib/esm/interfaces/SocketFilters.js.map +1 -1
- package/lib/esm/services/SocketIOService.js +2 -2
- package/lib/esm/services/SocketIOService.js.map +1 -1
- package/lib/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/class/SocketHandlersBuilder.d.ts +1 -1
- package/lib/types/decorators/reason.d.ts +25 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/interfaces/SocketFilters.d.ts +2 -1
- package/package.json +15 -15
- package/readme.md +2 -2
|
@@ -26,7 +26,7 @@ export declare class SocketHandlersBuilder {
|
|
|
26
26
|
* @param {Namespace} nsp
|
|
27
27
|
*/
|
|
28
28
|
onConnection(socket: Socket, nsp: Namespace): void;
|
|
29
|
-
onDisconnect(socket: Socket, nsp: Namespace): void;
|
|
29
|
+
onDisconnect(socket: Socket, nsp: Namespace, reason?: string): void;
|
|
30
30
|
/**
|
|
31
31
|
*
|
|
32
32
|
* @param {Socket} socket
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inject the disconnection reason into the decorated parameter.
|
|
3
|
+
*
|
|
4
|
+
* This decorator is used in conjunction with the `$onDisconnect` event handler to handle disconnection reasons in SocketIO services.
|
|
5
|
+
* It allows you to access the reason for the disconnection in your method implementation. For details please refer to the [Socket.io documentation](https://socket.io/docs/v4/server-api/#event-disconnect).
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* @SocketService("/nsp")
|
|
10
|
+
* export class MyWS {
|
|
11
|
+
* public async $onDisconnect(
|
|
12
|
+
* @Reason reason: string = ''
|
|
13
|
+
* ) {
|
|
14
|
+
* // your implementation
|
|
15
|
+
* }
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @experimental This decorator is experimental and may change or be removed in future versions.
|
|
20
|
+
* @param target
|
|
21
|
+
* @param {string} propertyKey
|
|
22
|
+
* @param {number} index
|
|
23
|
+
* @decorator
|
|
24
|
+
*/
|
|
25
|
+
export declare function Reason(target: unknown, propertyKey: string, index: number): void;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export * from "./decorators/inputAndBroadcastOthers";
|
|
|
15
15
|
export * from "./decorators/inputAndEmit";
|
|
16
16
|
export * from "./decorators/io";
|
|
17
17
|
export * from "./decorators/nsp";
|
|
18
|
+
export * from "./decorators/reason";
|
|
18
19
|
export * from "./decorators/socket";
|
|
19
20
|
export * from "./decorators/socketErr";
|
|
20
21
|
export * from "./decorators/socketEventName";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/socketio",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.33.0",
|
|
4
4
|
"description": "Socket.io package for Ts.ED framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"keywords": [
|
|
@@ -33,27 +33,27 @@
|
|
|
33
33
|
"tslib": "2.5.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@tsed/common": "7.
|
|
37
|
-
"@tsed/core": "7.
|
|
38
|
-
"@tsed/di": "7.
|
|
39
|
-
"@tsed/eslint": "7.
|
|
40
|
-
"@tsed/json-mapper": "7.
|
|
41
|
-
"@tsed/openspec": "7.
|
|
42
|
-
"@tsed/platform-middlewares": "7.
|
|
43
|
-
"@tsed/schema": "7.
|
|
44
|
-
"@tsed/socketio-testing": "7.
|
|
45
|
-
"@tsed/typescript": "7.
|
|
36
|
+
"@tsed/common": "7.33.0",
|
|
37
|
+
"@tsed/core": "7.33.0",
|
|
38
|
+
"@tsed/di": "7.33.0",
|
|
39
|
+
"@tsed/eslint": "7.33.0",
|
|
40
|
+
"@tsed/json-mapper": "7.33.0",
|
|
41
|
+
"@tsed/openspec": "7.33.0",
|
|
42
|
+
"@tsed/platform-middlewares": "7.33.0",
|
|
43
|
+
"@tsed/schema": "7.33.0",
|
|
44
|
+
"@tsed/socketio-testing": "7.33.0",
|
|
45
|
+
"@tsed/typescript": "7.33.0",
|
|
46
46
|
"eslint": "^8.12.0",
|
|
47
47
|
"express": "^4.17.1",
|
|
48
48
|
"socket.io": "4.4.1",
|
|
49
49
|
"socket.io-client": "^4.1.2"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@tsed/di": "^7.
|
|
53
|
-
"@tsed/json-mapper": "^7.
|
|
52
|
+
"@tsed/di": "^7.33.0",
|
|
53
|
+
"@tsed/json-mapper": "^7.33.0",
|
|
54
54
|
"@tsed/logger": ">=6.2.2",
|
|
55
|
-
"@tsed/platform-middlewares": "^7.
|
|
56
|
-
"@tsed/schema": "^7.
|
|
55
|
+
"@tsed/platform-middlewares": "^7.33.0",
|
|
56
|
+
"@tsed/schema": "^7.33.0",
|
|
57
57
|
"socket.io": ">=4.0.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependenciesMeta": {
|
package/readme.md
CHANGED
|
@@ -67,7 +67,7 @@ Example:
|
|
|
67
67
|
|
|
68
68
|
```typescript
|
|
69
69
|
import * as SocketIO from "socket.io";
|
|
70
|
-
import {SocketService, IO, Nsp, Socket, SocketSession} from "@tsed/socketio";
|
|
70
|
+
import {SocketService, IO, Nsp, Socket, SocketSession, Reason} from "@tsed/socketio";
|
|
71
71
|
|
|
72
72
|
@SocketService("/my-namespace")
|
|
73
73
|
export class MySocketService {
|
|
@@ -88,7 +88,7 @@ export class MySocketService {
|
|
|
88
88
|
/**
|
|
89
89
|
* Triggered when a client disconnects from the Namespace.
|
|
90
90
|
*/
|
|
91
|
-
$onDisconnect(@Socket socket: SocketIO.Socket) {}
|
|
91
|
+
$onDisconnect(@Socket socket: SocketIO.Socket, @Reason reason: string) {}
|
|
92
92
|
}
|
|
93
93
|
```
|
|
94
94
|
|