egg-wss
v1.0.0
Published
egg websocket plugin
Downloads
3
Readme
egg-wss
egg plugin for websocket
Install
$ npm i egg-wss --save
ps: the npm package name is "egg-wss" (not "egg-ws"), because the "egg-ws" is use by someone, but do nothing
Requirements
- Node.js >= 8.0
- Egg.js >= 2.0
Configuration
Change ${app_root}/config/plugin.js
to enable Socket.IO plugin:
// {app_root}/config/plugin.js
exports.io = {
enable: true,
package: 'egg-wss',
};
Deployment
Usage
Directory Structure
app
├── ws
│ ├── chat.js
config
└── plugin.js
example
/******************* app/ws/chat.js ****************/
// listen
module.exports = app => {
app.ws.on('message', function(data, flags) {
// console.log(data);
});
};
/******************** app/controller/home.js ********/
// send
async send() {
...
app.ws.send('hello world!!!')
...
}
Questions & Suggestions
Please open an issue here.