chensenlai 10988628a0 语音房项目初始化 | пре 5 година | |
---|---|---|
.. | ||
coverage | пре 5 година | |
example | пре 5 година | |
lib | пре 5 година | |
node_modules | пре 5 година | |
.editorconfig | пре 5 година | |
.npmignore | пре 5 година | |
.travis.yml | пре 5 година | |
History.md | пре 5 година | |
README.md | пре 5 година | |
package.json | пре 5 година |
Realtime web framework combine koa and socket.io.
This project is under development now.
socket.io
support koa style middleware when socket connect and disconnect.socket.io
's event handler support generator function.socket.io
's socket
object like koa
's context
, to compact with some koa
's middlewares.$ npm install koa.io --save
var koa = require('koa.io');
var app = koa();
// middleware for koa
app.use(function*() {
});
// middleware for scoket.io's connect and disconnect
app.io.use(function* (next) {
// on connect
yield* next;
// on disconnect
});
// router for socket event
app.io.route('new message', function* () {
// we tell the client to execute 'new message'
var message = this.args[0];
this.broadcast.emit('new message', message);
});
app.listen(3000);
Please check out this simple chat example.
MIT