Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated readme's with some additional methods that didn't seem to be covered. #38

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 8 additions & 1 deletion lib/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# API Reference

This gives details on the new top level objects for __express.io__.
Expand Down Expand Up @@ -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
Expand Down