Permalink
Browse files

fix previous merge

  • Loading branch information...
1 parent 0d9d289 commit 528efd8245af872d30979fdc51f02fef4e648a08 @tj committed Mar 26, 2013
Showing with 18 additions and 32 deletions.
  1. +18 −32 Readme.md
View
@@ -288,40 +288,26 @@ __Note:__ codecs must be defined on both the sending and receiving ends, otherwi
axon cannot properly decode the messages. You may of course ignore this
feature all together and simply pass encoded data to `.send()`.
-To use a codec in a socket pair, use the `format(<codec name>)` command. For example, to send json over a req/rep socket pair
+To use a codec in a socket pair, use the `format(<codec name>)` command. For example, to send json over a req/rep socket pair:
```
-var axon = require('axon'),
- requestSocket = axon.socket('req'),
- replySocket = axon.socket('rep');
-
-requestSocket.format('json')
-requestSocket.bind(3000);
-
-replySocket.format('json')
-replySocket.connect(3000)
-
-replySocket.on('message', function (data, cb) {
- // data is a json object
- console.log('reply socket received json data')
- console.dir(data)
- var output = {
- fizz: 'buzz'
- }
- cb(null, output)
-})
-var data = {
- foo: 'bar'
-}
-
-requestSocket.send(data, function(err, res){
- if (err) {
- console.dir(err)
- return
- }
- console.log('request socket callback received data')
- console.dir(res)
-})
+var axon = require('axon')
+ , req = axon.socket('req')
+ , rep = axon.socket('rep')
+
+req.format('json');
+req.bind(3000);
+
+rep.format('json');
+rep.connect(3000);
+
+rep.on('message', function(obj, reply){
+ reply(obj);
+});
+
+req.send({ hello: 'World' }, function(res){
+ console.log(res);
+});
```
## Performance

0 comments on commit 528efd8

Please sign in to comment.