{
  "name": "socket.io",
  "version": "0.9.14",
  "description": "Real-time apps made cross-browser & easy with a WebSocket-like API",
  "homepage": "http://socket.io",
  "keywords": [
    "websocket",
    "socket",
    "realtime",
    "socket.io",
    "comet",
    "ajax"
  ],
  "author": {
    "name": "Guillermo Rauch",
    "email": "guillermo@learnboost.com"
  },
  "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"
    }
  ],
  "repository": {
    "type": "git",
    "url": "https://github.com/LearnBoost/socket.io.git"
  },
  "dependencies": {
    "socket.io-client": "0.9.11",
    "policyfile": "0.0.4",
    "base64id": "0.1.0",
    "redis": "0.7.3"
  },
  "devDependencies": {
    "expresso": "0.9.2",
    "should": "*",
    "benchmark": "0.2.2",
    "microtime": "0.1.3-1",
    "colors": "0.5.1"
  },
  "optionalDependencies": {
    "redis": "0.7.3"
  },
  "main": "index",
  "engines": {
    "node": ">= 0.4.0"
  },
  "scripts": {
    "test": "make test"
  },
  "readme": "# Socket.IO\n\nSocket.IO is a Node.JS project that makes WebSockets and realtime possible in\nall browsers. It also enhances WebSockets by providing built-in multiplexing,\nhorizontal scalability, automatic JSON encoding/decoding, and more.\n\n## How to Install\n\n```bash\nnpm install socket.io\n```\n\n## How to use\n\nFirst, require `socket.io`:\n\n```js\nvar io = require('socket.io');\n```\n\nNext, attach it to a HTTP/HTTPS server. If you're using the fantastic `express`\nweb framework:\n\n#### Express 3.x\n\n```js\nvar app = express()\n  , server = require('http').createServer(app)\n  , io = io.listen(server);\n\nserver.listen(80);\n\nio.sockets.on('connection', function (socket) {\n  socket.emit('news', { hello: 'world' });\n  socket.on('my other event', function (data) {\n    console.log(data);\n  });\n});\n```\n\n#### Express 2.x\n\n```js\nvar app = express.createServer()\n  , io = io.listen(app);\n\napp.listen(80);\n\nio.sockets.on('connection', function (socket) {\n  socket.emit('news', { hello: 'world' });\n  socket.on('my other event', function (data) {\n    console.log(data);\n  });\n});\n```\n\nFinally, load it from the client side code:\n\n```html\n<script src=\"/socket.io/socket.io.js\"></script>\n<script>\n  var socket = io.connect('http://localhost');\n  socket.on('news', function (data) {\n    console.log(data);\n    socket.emit('my other event', { my: 'data' });\n  });\n</script>\n```\n\nFor more thorough examples, look at the `examples/` directory.\n\n## Short recipes\n\n### Sending and receiving events.\n\nSocket.IO allows you to emit and receive custom events.\nBesides `connect`, `message` and `disconnect`, you can emit custom events:\n\n```js\n// note, io.listen(<port>) will create a http server for you\nvar io = require('socket.io').listen(80);\n\nio.sockets.on('connection', function (socket) {\n  io.sockets.emit('this', { will: 'be received by everyone' });\n\n  socket.on('private message', function (from, msg) {\n    console.log('I received a private message by ', from, ' saying ', msg);\n  });\n\n  socket.on('disconnect', function () {\n    io.sockets.emit('user disconnected');\n  });\n});\n```\n\n### Storing data associated to a client\n\nSometimes it's necessary to store data associated with a client that's\nnecessary for the duration of the session.\n\n#### Server side\n\n```js\nvar io = require('socket.io').listen(80);\n\nio.sockets.on('connection', function (socket) {\n  socket.on('set nickname', function (name) {\n    socket.set('nickname', name, function () { socket.emit('ready'); });\n  });\n\n  socket.on('msg', function () {\n    socket.get('nickname', function (err, name) {\n      console.log('Chat message by ', name);\n    });\n  });\n});\n```\n\n#### Client side\n\n```html\n<script>\n  var socket = io.connect('http://localhost');\n\n  socket.on('connect', function () {\n    socket.emit('set nickname', prompt('What is your nickname?'));\n    socket.on('ready', function () {\n      console.log('Connected !');\n      socket.emit('msg', prompt('What is your message?'));\n    });\n  });\n</script>\n```\n\n### Restricting yourself to a namespace\n\nIf you have control over all the messages and events emitted for a particular\napplication, using the default `/` namespace works.\n\nIf you want to leverage 3rd-party code, or produce code to share with others,\nsocket.io provides a way of namespacing a `socket`.\n\nThis has the benefit of `multiplexing` a single connection. Instead of\nsocket.io using two `WebSocket` connections, it'll use one.\n\nThe following example defines a socket that listens on '/chat' and one for\n'/news':\n\n#### Server side\n\n```js\nvar io = require('socket.io').listen(80);\n\nvar chat = io\n  .of('/chat')\n  .on('connection', function (socket) {\n    socket.emit('a message', { that: 'only', '/chat': 'will get' });\n    chat.emit('a message', { everyone: 'in', '/chat': 'will get' });\n  });\n\nvar news = io\n  .of('/news');\n  .on('connection', function (socket) {\n    socket.emit('item', { news: 'item' });\n  });\n```\n\n#### Client side:\n\n```html\n<script>\n  var chat = io.connect('http://localhost/chat')\n    , news = io.connect('http://localhost/news');\n\n  chat.on('connect', function () {\n    chat.emit('hi!');\n  });\n\n  news.on('news', function () {\n    news.emit('woot');\n  });\n</script>\n```\n\n### Sending volatile messages.\n\nSometimes certain messages can be dropped. Let's say you have an app that\nshows realtime tweets for the keyword `bieber`. \n\nIf a certain client is not ready to receive messages (because of network slowness\nor other issues, or because he's connected through long polling and is in the\nmiddle of a request-response cycle), if he doesn't receive ALL the tweets related\nto bieber your application won't suffer.\n\nIn that case, you might want to send those messages as volatile messages.\n\n#### Server side\n\n```js\nvar io = require('socket.io').listen(80);\n\nio.sockets.on('connection', function (socket) {\n  var tweets = setInterval(function () {\n    getBieberTweet(function (tweet) {\n      socket.volatile.emit('bieber tweet', tweet);\n    });\n  }, 100);\n\n  socket.on('disconnect', function () {\n    clearInterval(tweets);\n  });\n});\n```\n\n#### Client side\n\nIn the client side, messages are received the same way whether they're volatile\nor not.\n\n### Getting acknowledgements\n\nSometimes, you might want to get a callback when the client confirmed the message\nreception.\n\nTo do this, simply pass a function as the last parameter of `.send` or `.emit`.\nWhat's more, when you use `.emit`, the acknowledgement is done by you, which\nmeans you can also pass data along:\n\n#### Server side\n\n```js\nvar io = require('socket.io').listen(80);\n\nio.sockets.on('connection', function (socket) {\n  socket.on('ferret', function (name, fn) {\n    fn('woot');\n  });\n});\n```\n\n#### Client side\n\n```html\n<script>\n  var socket = io.connect(); // TIP: .connect with no args does auto-discovery\n  socket.on('connect', function () { // TIP: you can avoid listening on `connect` and listen on events directly too!\n    socket.emit('ferret', 'tobi', function (data) {\n      console.log(data); // data will be 'woot'\n    });\n  });\n</script>\n```\n\n### Broadcasting messages\n\nTo broadcast, simply add a `broadcast` flag to `emit` and `send` method calls.\nBroadcasting means sending a message to everyone else except for the socket\nthat starts it.\n\n#### Server side\n\n```js\nvar io = require('socket.io').listen(80);\n\nio.sockets.on('connection', function (socket) {\n  socket.broadcast.emit('user connected');\n  socket.broadcast.json.send({ a: 'message' });\n});\n```\n\n### Rooms\n\nSometimes you want to put certain sockets in the same room, so that it's easy\nto broadcast to all of them together.\n\nThink of this as built-in channels for sockets. Sockets `join` and `leave`\nrooms in each socket.\n\n#### Server side\n\n```js\nvar io = require('socket.io').listen(80);\n\nio.sockets.on('connection', function (socket) {\n  socket.join('justin bieber fans');\n  socket.broadcast.to('justin bieber fans').emit('new fan');\n  io.sockets.in('rammstein fans').emit('new non-fan');\n});\n```\n\n### Using it just as a cross-browser WebSocket\n\nIf you just want the WebSocket semantics, you can do that too.\nSimply leverage `send` and listen on the `message` event:\n\n#### Server side\n\n```js\nvar io = require('socket.io').listen(80);\n\nio.sockets.on('connection', function (socket) {\n  socket.on('message', function () { });\n  socket.on('disconnect', function () { });\n});\n```\n\n#### Client side\n\n```html\n<script>\n  var socket = io.connect('http://localhost/');\n  socket.on('connect', function () {\n    socket.send('hi');\n\n    socket.on('message', function (msg) {\n      // my msg\n    });\n  });\n</script>\n```\n\n### Changing configuration\n\nConfiguration in socket.io is TJ-style:\n\n#### Server side\n\n```js\nvar io = require('socket.io').listen(80);\n\nio.configure(function () {\n  io.set('transports', ['websocket', 'flashsocket', 'xhr-polling']);\n});\n\nio.configure('development', function () {\n  io.set('transports', ['websocket', 'xhr-polling']);\n  io.enable('log');\n});\n```\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2011 Guillermo Rauch &lt;guillermo@learnboost.com&gt;\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n",
  "_id": "socket.io@0.9.14",
  "_from": "socket.io"
}
