@forinda/kickjs-ws 1.2.12 → 1.2.13
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/README.md +53 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# @forinda/kickjs-ws
|
|
2
|
+
|
|
3
|
+
WebSocket support with decorators, namespaces, rooms, and DI integration for KickJS.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Using the KickJS CLI (recommended — auto-installs peer dependencies)
|
|
9
|
+
kick add ws
|
|
10
|
+
|
|
11
|
+
# Manual install
|
|
12
|
+
pnpm add @forinda/kickjs-ws ws
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- `WsAdapter` — lifecycle adapter that attaches a WebSocket server to your app
|
|
18
|
+
- Decorator-driven handlers: `@WsController`, `@OnConnect`, `@OnDisconnect`, `@OnMessage`, `@OnError`
|
|
19
|
+
- `WsContext` — typed context for WebSocket handlers
|
|
20
|
+
- `RoomManager` — built-in room/namespace management
|
|
21
|
+
|
|
22
|
+
## Quick Example
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { WsAdapter, WsController, OnConnect, OnMessage, WsContext } from '@forinda/kickjs-ws'
|
|
26
|
+
|
|
27
|
+
@WsController('/chat')
|
|
28
|
+
class ChatHandler {
|
|
29
|
+
@OnConnect()
|
|
30
|
+
onConnect(ctx: WsContext) {
|
|
31
|
+
console.log('Client connected')
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@OnMessage('message')
|
|
35
|
+
onMessage(ctx: WsContext) {
|
|
36
|
+
ctx.broadcast(ctx.data)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// In bootstrap
|
|
41
|
+
bootstrap({
|
|
42
|
+
modules,
|
|
43
|
+
adapters: [new WsAdapter()],
|
|
44
|
+
})
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Documentation
|
|
48
|
+
|
|
49
|
+
[Full documentation](https://forinda.github.io/kick-js/guide/websockets)
|
|
50
|
+
|
|
51
|
+
## License
|
|
52
|
+
|
|
53
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forinda/kickjs-ws",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.13",
|
|
4
4
|
"description": "WebSocket support with decorators, namespaces, rooms, and DI integration for KickJS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"kickjs",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"reflect-metadata": "^0.2.2",
|
|
43
43
|
"ws": "^8.18.0",
|
|
44
|
-
"@forinda/kickjs-core": "1.2.
|
|
44
|
+
"@forinda/kickjs-core": "1.2.13"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@swc/core": "^1.7.28",
|