New: Introducing PHP and Composer Support.Read the Announcement
Socket
Book a DemoInstallSign in
Socket

koa.io

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa.io

realtime web framework combine koa and socket.io

npmnpm
Version
0.0.0
Version published
Weekly downloads
15
-25%
Maintainers
1
Weekly downloads
 
Created
Source

koa.io

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();

app.use(function*() {
  // koa middlewares
});


// 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.socket.broadcast.emit('new message', message);
});

app.listen(3000);

Please check out this simple chat example.

License

MIT

Keywords

koa

FAQs

Package last updated on 24 Oct 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts