{
  "name": "socket.io",
  "version": "1.7.3",
  "description": "node.js realtime framework server",
  "keywords": [
    "realtime",
    "framework",
    "websocket",
    "tcp",
    "events",
    "socket",
    "io"
  ],
  "main": "./lib/index",
  "files": [
    "lib/"
  ],
  "license": "MIT",
  "repository": {
    "type": "git",
    "url": "git://github.com/socketio/socket.io"
  },
  "scripts": {
    "test": "gulp test"
  },
  "dependencies": {
    "debug": "2.3.3",
    "engine.io": "1.8.3",
    "has-binary": "0.1.7",
    "object-assign": "4.1.0",
    "socket.io-adapter": "0.5.0",
    "socket.io-client": "1.7.3",
    "socket.io-parser": "2.3.1"
  },
  "devDependencies": {
    "babel-preset-es2015": "6.3.13",
    "del": "2.2.0",
    "expect.js": "0.3.1",
    "gulp": "3.9.0",
    "gulp-babel": "6.1.1",
    "gulp-istanbul": "0.10.3",
    "gulp-mocha": "2.2.0",
    "gulp-task-listing": "1.0.1",
    "istanbul": "0.4.1",
    "mocha": "2.3.4",
    "superagent": "1.6.1",
    "supertest": "1.1.0"
  },
  "contributors": [
    {
      "name": "Guillermo Rauch",
      "email": "rauchg@gmail.com"
    },
    {
      "name": "Arnout Kazemier",
      "email": "info@3rd-eden.com"
    },
    {
      "name": "Vladimir Dronnikov",
      "email": "dronnikov@gmail.com"
    },
    {
      "name": "Einar Otto Stangvik",
      "email": "einaros@gmail.com"
    }
  ],
  "readme": "\n# socket.io\n\n[![Build Status](https://secure.travis-ci.org/socketio/socket.io.svg?branch=master)](https://travis-ci.org/socketio/socket.io)\n[![Dependency Status](https://david-dm.org/socketio/socket.io.svg)](https://david-dm.org/socketio/socket.io)\n[![devDependency Status](https://david-dm.org/socketio/socket.io/dev-status.svg)](https://david-dm.org/socketio/socket.io#info=devDependencies)\n[![NPM version](https://badge.fury.io/js/socket.io.svg)](https://www.npmjs.com/package/socket.io)\n![Downloads](https://img.shields.io/npm/dm/socket.io.svg?style=flat)\n[![](http://slack.socket.io/badge.svg?)](http://slack.socket.io)\n\n## How to use\n\nThe following example attaches socket.io to a plain Node.JS\nHTTP server listening on port `3000`.\n\n```js\nvar server = require('http').createServer();\nvar io = require('socket.io')(server);\nio.on('connection', function(client){\n  client.on('event', function(data){});\n  client.on('disconnect', function(){});\n});\nserver.listen(3000);\n```\n\n### Standalone\n\n```js\nvar io = require('socket.io')();\nio.on('connection', function(client){});\nio.listen(3000);\n```\n\n### In conjunction with Express\n\nStarting with **3.0**, express applications have become request handler\nfunctions that you pass to `http` or `http` `Server` instances. You need\nto pass the `Server` to `socket.io`, and not the express application\nfunction.\n\n```js\nvar app = require('express')();\nvar server = require('http').createServer(app);\nvar io = require('socket.io')(server);\nio.on('connection', function(){ /* … */ });\nserver.listen(3000);\n```\n\n### In conjunction with Koa\n\nLike Express.JS, Koa works by exposing an application as a request\nhandler function, but only by calling the `callback` method.\n\n```js\nvar app = require('koa')();\nvar server = require('http').createServer(app.callback());\nvar io = require('socket.io')(server);\nio.on('connection', function(){ /* … */ });\nserver.listen(3000);\n```\n\n## API\n\n### Server\n\n  Exposed by `require('socket.io')`.\n\n### Server()\n\n  Creates a new `Server`. Works with and without `new`:\n\n  ```js\n  var io = require('socket.io')();\n  // or\n  var Server = require('socket.io');\n  var io = new Server();\n  ```\n\n### Server(opts:Object)\n\n  Optionally, the first or second argument (see below) of the `Server`\n  constructor can be an options object.\n\n  The following options are supported:\n\n  - `serveClient` sets the value for Server#serveClient()\n  - `path` sets the value for Server#path()\n\n  The same options passed to socket.io are always passed to\n  the `engine.io` `Server` that gets created. See engine.io\n  [options](https://github.com/socketio/engine.io#methods-1)\n  as reference.\n\n### Server(srv:http#Server, opts:Object)\n\n  Creates a new `Server` and attaches it to the given `srv`. Optionally\n  `opts` can be passed.\n\n### Server(port:Number, opts:Object)\n\n  Binds socket.io to a new `http.Server` that listens on `port`.\n\n### Server#serveClient(v:Boolean):Server\n\n  If `v` is `true` the attached server (see `Server#attach`) will serve\n  the client files. Defaults to `true`.\n\n  This method has no effect after `attach` is called.\n\n  ```js\n  // pass a server and the `serveClient` option\n  var io = require('socket.io')(http, { serveClient: false });\n\n  // or pass no server and then you can call the method\n  var io = require('socket.io')();\n  io.serveClient(false);\n  io.attach(http);\n  ```\n\n  If no arguments are supplied this method returns the current value.\n\n### Server#path(v:String):Server\n\n  Sets the path `v` under which `engine.io` and the static files will be\n  served. Defaults to `/socket.io`.\n\n  If no arguments are supplied this method returns the current value.\n\n### Server#adapter(v:Adapter):Server\n\n  Sets the adapter `v`. Defaults to an instance of the `Adapter` that\n  ships with socket.io which is memory based. See\n  [socket.io-adapter](https://github.com/socketio/socket.io-adapter).\n\n  If no arguments are supplied this method returns the current value.\n\n### Server#origins(v:String):Server\n\n  Sets the allowed origins `v`. Defaults to any origins being allowed.\n\n  If no arguments are supplied this method returns the current value.\n\n### Server#origins(v:Function):Server\n\n  Sets the allowed origins as dynamic function. Function takes two arguments `origin:String` and `callback(error, success)`, where `success` is a boolean value indicating whether origin is allowed or not.\n\n  __Potential drawbacks__:\n  * in some situations, when it is not possible to determine `origin` it may have value of `*`\n  * As this function will be executed for every request, it is advised to make this function work as fast as possible\n  * If `socket.io` is used together with `Express`, the CORS headers will be affected only for `socket.io` requests. For Express can use [cors](https://github.com/expressjs/cors).\n\n\n### Server#sockets:Namespace\n\n  The default (`/`) namespace.\n\n### Server#attach(srv:http#Server, opts:Object):Server\n\n  Attaches the `Server` to an engine.io instance on `srv` with the\n  supplied `opts` (optionally).\n\n### Server#attach(port:Number, opts:Object):Server\n\n  Attaches the `Server` to an engine.io instance that is bound to `port`\n  with the given `opts` (optionally).\n\n### Server#listen\n\n  Synonym of `Server#attach`.\n\n### Server#bind(srv:engine#Server):Server\n\n  Advanced use only. Binds the server to a specific engine.io `Server`\n  (or compatible API) instance.\n\n### Server#onconnection(socket:engine#Socket):Server\n\n  Advanced use only. Creates a new `socket.io` client from the incoming\n  engine.io (or compatible API) `socket`.\n\n### Server#of(nsp:String):Namespace\n\n  Initializes and retrieves the given `Namespace` by its pathname\n  identifier `nsp`.\n\n  If the namespace was already initialized it returns it immediately.\n\n### Server#emit\n\n  Emits an event to all connected clients. The following two are\n  equivalent:\n\n  ```js\n  var io = require('socket.io')();\n  io.sockets.emit('an event sent to all connected clients');\n  io.emit('an event sent to all connected clients');\n  ```\n\n  For other available methods, see `Namespace` below.\n\n### Server#close([fn:Function])\n\n  Closes socket.io server.\n  \n  The optional `fn` is passed to the `server.close([callback])` method of the \n  core `net` module and is called on error or when all connections are closed. \n  The callback is expected to implement the common single argument `err` \n  signature (if any).\n\n  ```js\n  var Server = require('socket.io');\n  var PORT   = 3030;\n  var server = require('http').Server();\n\n  var io = Server(PORT);\n\n  io.close(); // Close current server\n\n  server.listen(PORT); // PORT is free to use\n\n  io = Server(server);\n  ```\n\n### Server#use\n\n  See `Namespace#use` below.\n\n### Namespace\n\n  Represents a pool of sockets connected under a given scope identified\n  by a pathname (eg: `/chat`).\n\n  By default the client always connects to `/`.\n\n#### Events\n\n  - `connection` / `connect`. Fired upon a connection.\n\n    Parameters:\n    - `Socket` the incoming socket.\n\n### Namespace#name:String\n\n  The namespace identifier property.\n\n### Namespace#connected:Object<Socket>\n\n  Hash of `Socket` objects that are connected to this namespace indexed\n  by `id`.\n\n### Namespace#clients(fn:Function)\n\n  Gets a list of client IDs connected to this namespace (across all nodes if applicable).\n\n  An example to get all clients in a namespace:\n\n  ```js\n  var io = require('socket.io')();\n  io.of('/chat').clients(function(error, clients){\n    if (error) throw error;\n    console.log(clients); // => [PZDoMHjiu8PYfRiKAAAF, Anw2LatarvGVVXEIAAAD]\n  });\n  ```\n\n  An example to get all clients in namespace's room:\n\n  ```js\n  var io = require('socket.io')();\n  io.of('/chat').in('general').clients(function(error, clients){\n    if (error) throw error;\n    console.log(clients); // => [Anw2LatarvGVVXEIAAAD]\n  });\n  ```\n\n  As with broadcasting, the default is all clients from the default namespace ('/'):\n\n  ```js\n  var io = require('socket.io')();\n  io.clients(function(error, clients){\n    if (error) throw error;\n    console.log(clients); // => [6em3d4TJP8Et9EMNAAAA, G5p55dHhGgUnLUctAAAB]\n  });\n  ```\n\n### Namespace#use(fn:Function):Namespace\n\n  Registers a middleware, which is a function that gets executed for\n  every incoming `Socket`, and receives as parameters the socket and a\n  function to optionally defer execution to the next registered\n  middleware.\n\n  ```js\n  var io = require('socket.io')();\n  io.use(function(socket, next){\n    if (socket.request.headers.cookie) return next();\n    next(new Error('Authentication error'));\n  });\n  ```\n\n  Errors passed to middleware callbacks are sent as special `error`\n  packets to clients.\n\n### Socket\n\n  A `Socket` is the fundamental class for interacting with browser\n  clients. A `Socket` belongs to a certain `Namespace` (by default `/`)\n  and uses an underlying `Client` to communicate.\n  \n  It should be noted the `Socket` doesn't relate directly to the actual\n  underlying TCP/IP `socket` and it is only the name of the class.\n\n### Socket#use(fn:Function):Socket\n\n  Registers a middleware, which is a function that gets executed for\n  every incoming `Packet` and receives as parameter the packet and a\n  function to optionally defer execution to the next registered\n  middleware.\n\n  ```js\n  var io = require('socket.io')();\n  io.on('connection', function(socket){\n    socket.use(function(packet, next){\n      if (packet.doge === true) return next();\n      next(new Error('Not a doge error'));\n  });\n  ```\n\n  Errors passed to middleware callbacks are sent as special `error`\n  packets to clients.\n\n### Socket#rooms:Object\n\n  A hash of strings identifying the rooms this client is in, indexed by\n  room name.\n\n### Socket#client:Client\n\n  A reference to the underlying `Client` object.\n\n### Socket#conn:Socket\n\n  A reference to the underlying `Client` transport connection (engine.io\n  `Socket` object). This allows access to the IO transport layer, which\n  still (mostly) abstracts the actual TCP/IP socket.\n\n### Socket#request:Request\n\n  A getter proxy that returns the reference to the `request` that\n  originated the underlying engine.io `Client`. Useful for accessing\n  request headers such as `Cookie` or `User-Agent`.\n\n### Socket#id:String\n\n  A unique identifier for the session, that comes from the\n  underlying `Client`.\n\n### Socket#emit(name:String[, …]):Socket\n\n  Emits an event identified by the string `name` to the client.\n  Any other parameters can be included.\n\n  All datastructures are supported, including `Buffer`. JavaScript\n  functions can't be serialized/deserialized.\n\n  ```js\n  var io = require('socket.io')();\n  io.on('connection', function(client){\n    client.emit('an event', { some: 'data' });\n  });\n  ```\n\n### Socket#join(name:String[, fn:Function]):Socket\n\n  Adds the client to the `room`, and fires optionally a callback `fn`\n  with `err` signature (if any).\n\n  The client is automatically a member of a room identified with its\n  session id (see `Socket#id`).\n\n  The mechanics of joining  rooms are handled by the `Adapter`\n  that has been configured (see `Server#adapter` above), defaulting to\n  [socket.io-adapter](https://github.com/socketio/socket.io-adapter).\n\n### Socket#leave(name:String[, fn:Function]):Socket\n\n  Removes the client from `room`, and fires optionally a callback `fn`\n  with `err` signature (if any).\n\n  **Rooms are left automatically upon disconnection**.\n\n  The mechanics of leaving rooms are handled by the `Adapter`\n  that has been configured (see `Server#adapter` above), defaulting to\n  [socket.io-adapter](https://github.com/socketio/socket.io-adapter).\n\n### Socket#to(room:String):Socket\n\n  Sets a modifier for a subsequent event emission that the event will\n  only be _broadcasted_ to clients that have joined the given `room`.\n\n  To emit to multiple rooms, you can call `to` several times.\n\n  ```js\n  var io = require('socket.io')();\n  io.on('connection', function(client){\n    client.to('others').emit('an event', { some: 'data' });\n  });\n  ```\n\n### Socket#in(room:String):Socket\n\n  Same as `Socket#to`\n\n### Socket#compress(v:Boolean):Socket\n\n  Sets a modifier for a subsequent event emission that the event data will\n  only be _compressed_ if the value is `true`. Defaults to `true` when you don't call the method.\n\n  ```js\n  var io = require('socket.io')();\n  io.on('connection', function(client){\n    client.compress(false).emit('an event', { some: 'data' });\n  });\n  ```\n  \n### Socket#disconnect(close:Boolean):Socket\n    \n  Disconnects this client. If value of close is `true`, closes the underlying connection. \n  Otherwise, it just disconnects the namespace.\n\n#### Events\n\n- `disconnect`\n    - Fired upon disconnection.\n    - **Arguments**\n      - `String`: the reason of the disconnection (either client or server-side)\n- `error`\n    - Fired when an error occurs.\n    - **Arguments**\n      - `Object`: error data\n- `disconnecting`\n    - Fired when the client is going to be disconnected (but hasn't left its `rooms` yet).\n    - **Arguments**\n      - `String`: the reason of the disconnection (either client or server-side)\n\nThese are reserved events (along with `connect`, `newListener` and `removeListener`) which cannot be used as event names.\n\n\n### Client\n\n  The `Client` class represents an incoming transport (engine.io)\n  connection. A `Client` can be associated with many multiplexed `Socket`s\n  that belong to different `Namespace`s.\n\n### Client#conn\n\n  A reference to the underlying `engine.io` `Socket` connection.\n\n### Client#request\n\n  A getter proxy that returns the reference to the `request` that\n  originated the engine.io connection. Useful for accessing\n  request headers such as `Cookie` or `User-Agent`.\n\n## Debug / logging\n\nSocket.IO is powered by [debug](https://github.com/visionmedia/debug).\nIn order to see all the debug output, run your app with the environment variable\n`DEBUG` including the desired scope.\n\nTo see the output from all of Socket.IO's debugging scopes you can use:\n\n```\nDEBUG=socket.io* node myapp\n```\n\n## Testing\n\n```\nnpm test\n```\nThis runs the `gulp` task `test`. By default the test will be run with the source code in `lib` directory.\n\nSet the environmental variable `TEST_VERSION` to `compat` to test the transpiled es5-compat version of the code.\n\nThe `gulp` task `test` will always transpile the source code into es5 and export to `dist` first before running the test.\n\n## License\n\n[MIT](LICENSE)\n",
  "readmeFilename": "Readme.md",
  "bugs": {
    "url": "https://github.com/socketio/socket.io/issues"
  },
  "homepage": "https://github.com/socketio/socket.io",
  "_id": "socket.io@1.7.3",
  "_shasum": "b8af9caba00949e568e369f1327ea9be9ea2461b",
  "_from": "socket.io@^1.7.2",
  "_resolved": "https://registry.npmjs.org/socket.io/-/socket.io-1.7.3.tgz"
}
