GithubHelp home page GithubHelp logo

tisseur2toile / socket.io Goto Github PK

View Code? Open in Web Editor NEW

This project forked from socketio/socket.io

0.0 2.0 0.0 11.79 MB

Realtime application framework (Node.JS server)

Home Page: http://socket.io

License: MIT License

Makefile 0.10% JavaScript 99.90%

socket.io's Introduction

socket.io

Build Status Dependency Status devDependency Status NPM version Downloads

Installation

npm install socket.io --save

How to use

The following example attaches socket.io to a plain Node.JS HTTP server listening on port 3000.

var server = require('http').createServer();
var io = require('socket.io')(server);
io.on('connection', function(client){
  client.on('event', function(data){});
  client.on('disconnect', function(){});
});
server.listen(3000);

Standalone

var io = require('socket.io')();
io.on('connection', function(client){});
io.listen(3000);

In conjunction with Express

Starting with 3.0, express applications have become request handler functions that you pass to http or http Server instances. You need to pass the Server to socket.io, and not the express application function.

var app = require('express')();
var server = require('http').createServer(app);
var io = require('socket.io')(server);
io.on('connection', function(){ /* … */ });
server.listen(3000);

In conjunction with Koa

Like Express.JS, Koa works by exposing an application as a request handler function, but only by calling the callback method.

var app = require('koa')();
var server = require('http').createServer(app.callback());
var io = require('socket.io')(server);
io.on('connection', function(){ /* … */ });
server.listen(3000);

API

See API.

Debug / logging

Socket.IO is powered by debug. In order to see all the debug output, run your app with the environment variable DEBUG including the desired scope.

To see the output from all of Socket.IO's debugging scopes you can use:

DEBUG=socket.io* node myapp

Testing

npm test

This runs the gulp task test. By default the test will be run with the source code in lib directory.

Set the environmental variable TEST_VERSION to compat to test the transpiled es5-compat version of the code.

The gulp task test will always transpile the source code into es5 and export to dist first before running the test.

License

MIT

socket.io's People

Contributors

3rd-eden avatar ad7six avatar akamensky avatar asyncanup avatar bananaappletw avatar crickeys avatar darrachequesne avatar defunctzombie avatar digawp avatar doozr avatar dshaw avatar dvv avatar einaros avatar ericz avatar gavinuhma avatar grant avatar kevin-roark avatar martinthomson avatar matthewmueller avatar mattrobenolt avatar nkzawa avatar paradite avatar perrin4869 avatar rase- avatar rauchg avatar tj avatar tripu avatar tw0517tw avatar xaroth8088 avatar zweihan avatar

Watchers

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