diff --git a/README.md b/README.md index 2082488..c349f14 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,24 @@ app.io.route('my-realtime-route', function(req) { // respond to the event }); ``` - +Or put your routes into a separate file for that nice and tidy look +```js +//in app.js pass in "app" so you can use it anywhere. +var realtime = require('./realtime')(app) +app.io.route('ready', realtime.ready ) + +//in realtime.js +module.exports = function(app){ + return { + ready: function(req) { + req.io.emit('lessClutter', {separate: "those concerns"}) + }, + set: function(req){ + app.io.broadcast('talkToServer', {to: "Everyone."}) + } + } +}; +``` ## Automatic Session Support Sessions work automatically, just set them up like normal using express. diff --git a/lib/README.md b/lib/README.md index 48b81c8..f519ef1 100644 --- a/lib/README.md +++ b/lib/README.md @@ -1,4 +1,3 @@ - # API Reference This gives details on the new top level objects for __express.io__. @@ -40,6 +39,14 @@ app.io.route('special', function(req) { }) ``` +You can also access all of the socket.io sockets, an example to disconnect all clients before shutdown +```js +app.io.sockets.clients().forEach(function (socket) { + socket.disconnect(); + logger.info(socket.username + ' disconnected for shutdown'); +}); +``` + You can also use the `AppIO` object to configure your io server. For available options, check [here](https://github.com/LearnBoost/Socket.IO/wiki/Configuring-Socket.IO). ```js