koajs / Koa.io
Realtime web framework combine koa and socket.io.
Stars: ✭ 427
Programming Languages
javascript
184084 projects - #8 most used programming language
koa.io
![Gitter](https://badges.gitter.im/Join Chat.svg)
Realtime web framework combine koa and socket.io.
This project is under development now.
Feature
-
socket.io
support koa style middleware when socket connect and disconnect. - socket event route support.
- Make
socket.io
's event handler support generator function. - Extent
socket.io
'ssocket
object likekoa
'scontext
, to compact with somekoa
's middlewares.
Installation
$ npm install koa.io --save
Usage
var koa = require('koa.io');
var app = koa();
// middleware for koa
app.use(function*() {
});
// middleware for socket.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.
License
MIT
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].