1
1
# egg-websocket-plugin
2
2
3
3
[ ![ NPM version] [ npm-image ]] [ npm-url ]
4
- [ ![ build status] [ travis-image ]] [ travis-url ]
5
- [ ![ Test coverage] [ codecov-image ]] [ codecov-url ]
6
- [ ![ David deps] [ david-image ]] [ david-url ]
7
4
[ ![ Known Vulnerabilities] [ snyk-image ]] [ snyk-url ]
8
5
[ ![ npm download] [ download-image ]] [ download-url ]
9
6
10
7
[ npm-image ] : https://img.shields.io/npm/v/egg-websocket-plugin.svg?style=flat-square
11
8
[ npm-url ] : https://npmjs.org/package/egg-websocket-plugin
12
- [ travis-image ] : https://img.shields.io/travis/eggjs/egg-websocket-plugin.svg?style=flat-square
13
- [ travis-url ] : https://travis-ci.org/eggjs/egg-websocket-plugin
14
- [ codecov-image ] : https://img.shields.io/codecov/c/github/eggjs/egg-websocket-plugin.svg?style=flat-square
15
- [ codecov-url ] : https://codecov.io/github/eggjs/egg-websocket-plugin?branch=master
16
- [ david-image ] : https://img.shields.io/david/eggjs/egg-websocket-plugin.svg?style=flat-square
17
- [ david-url ] : https://david-dm.org/eggjs/egg-websocket-plugin
18
9
[ snyk-image ] : https://snyk.io/test/npm/egg-websocket-plugin/badge.svg?style=flat-square
19
10
[ snyk-url ] : https://snyk.io/test/npm/egg-websocket-plugin
20
11
[ download-image ] : https://img.shields.io/npm/dm/egg-websocket-plugin.svg?style=flat-square
@@ -56,7 +47,7 @@ app.ws.route('/ws', app.controller.home.hello);
56
47
app .ws .route (' /foo/:id' , app .controller .home .foo );
57
48
```
58
49
59
- ### 3. 配置全局中间件 【可选】
50
+ ### 3. 配置 WebSocket 全局中间件 【可选】
60
51
61
52
``` js
62
53
// app/router.js
@@ -83,7 +74,7 @@ function middleware(ctx, next) {
83
74
app .ws .route (' /ws' , middleware, app .controller .home .hello );
84
75
```
85
76
86
- ### 5. 禁用 app 全局中间件
77
+ ### 5. 禁用 App 全局中间件
87
78
88
79
> 插件默认会使用 app.use(...) 注册的中间件,如果你不想使用它们,或者这些插件与 websocket 有冲突,你可以在 ` config.default.js ` 中禁用它们
89
80
@@ -108,7 +99,7 @@ export default class HomeController extends Controller {
108
99
throw new Error (' this function can only be use in websocket router' );
109
100
}
110
101
111
- console .log (` clients: ${ app . ws . clients . size } ` );
102
+ console .log (' client connected ' );
112
103
113
104
ctx .websocket
114
105
.on (' message' , (msg ) => {
0 commit comments