GithubHelp home page GithubHelp logo

pukapukan / koa.io Goto Github PK

View Code? Open in Web Editor NEW

This project forked from koajs/koa.io

0.0 2.0 0.0 434 KB

Realtime web framework combine koa and socket.io.

JavaScript 94.06% HTML 1.67% CSS 4.27%

koa.io's Introduction

koa.io

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

NPM version build status Test coverage Dependency Status devDependency Status node version

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 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

koa.io's People

Contributors

dead-horse avatar ariporad avatar greenkeeperio-bot avatar rashfael avatar scttcper avatar gitter-badger avatar travisjeffery avatar stanleycyang avatar

Watchers

James Cloos avatar Jason Park avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.