chensenlai 10988628a0 语音房项目初始化 5 anos atrás
..
coverage 10988628a0 语音房项目初始化 5 anos atrás
example 10988628a0 语音房项目初始化 5 anos atrás
lib 10988628a0 语音房项目初始化 5 anos atrás
node_modules 10988628a0 语音房项目初始化 5 anos atrás
.editorconfig 10988628a0 语音房项目初始化 5 anos atrás
.npmignore 10988628a0 语音房项目初始化 5 anos atrás
.travis.yml 10988628a0 语音房项目初始化 5 anos atrás
History.md 10988628a0 语音房项目初始化 5 anos atrás
README.md 10988628a0 语音房项目初始化 5 anos atrás
package.json 10988628a0 语音房项目初始化 5 anos atrás

README.md

koa.io

Gitter

NPM version build status Test coverage David deps node version Gittip

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's socket object like koa's context, to compact with some koa'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 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.

License

MIT