Skip to content

Commit

Permalink
doc [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanGRomano committed Jun 28, 2014
1 parent 1c44989 commit a947ae6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ io.use(router);
* Gives you more control over how events are handled.
* Attach `Router` instances to other `Router` instances.
* Support for "wildcard" (*) and Regular Expression matching.
* Event consumption and propagation.

# Examples

Expand Down Expand Up @@ -61,6 +62,8 @@ router.on(/^\w+/, function (socket, args, next) {
router.on(function (socket, args) {
//emits back to the client, and ends the chain.
//Think `res.end()` for express.
//calling `emit()` consumes the event which means no other handlers
//get a chance to process it.
socket.emit(args.shift(), args);
});

Expand All @@ -73,14 +76,14 @@ var io = require('socket.io')(3000);
io.use(router);
```

Here is an example of *not* handling a message and letting [socket.io](https://github.com/Automattic/socket.io "socket.io")
Here is an example of *not* consuming the event and letting [socket.io](https://github.com/Automattic/socket.io "socket.io")
handle things *business as usual*.

```javascript

var router = require('socket.io-events')();
router.on(function (socket, args, next) {
//do something!
//do something, but don't consume it.
next();
});

Expand Down

0 comments on commit a947ae6

Please sign in to comment.