koa.io
realtime web framework combine koa and socket.io
Last updated 5 years ago by dead_horse .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install koa.io 
SYNC missed versions from official npm registry.

koa.io

![Gitter](https://badges.gitter.im/Join Chat.svg)

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

Current Tags

  • 0.0.3                                ...           latest (5 years ago)

4 Versions

  • 0.0.3                                ...           5 years ago
  • 0.0.2                                ...           6 years ago
  • 0.0.1                                ...           6 years ago
  • 0.0.0                                ...           6 years ago
Downloads
Today 1
This Week 1
This Month 2
Last Day 0
Last Week 1
Last Month 11
Dependencies (9)
Dev Dependencies (9)

Copyright 2014 - 2017 © taobao.org |