Skip to content
Browse files

update client-server example to use JSONStream itself

  • Loading branch information...
1 parent 358321e commit 20d6e4ea9e835d380e80226811cef50953428a61 @substack committed Aug 27, 2012
Showing with 9 additions and 2 deletions.
  1. +4 −1 example/client-server/client.js
  2. +5 −1 example/client-server/server.js
View
5 example/client-server/client.js
@@ -1,7 +1,10 @@
var emitStream = require('../../');
+var JSONStream = require('JSONStream');
var net = require('net');
-var stream = net.connect(5555);
+var stream = net.connect(5555)
+ .pipe(JSONStream.parse([true]))
+;
var ev = emitStream(stream);
ev.on('ping', function (t) {
View
6 example/client-server/server.js
@@ -1,12 +1,16 @@
var emitStream = require('../../');
+var JSONStream = require('JSONStream');
var EventEmitter = require('events').EventEmitter;
var net = require('net');
var server = (function () {
var ev = createEmitter();
return net.createServer(function (stream) {
- emitStream(ev).pipe(stream);
+ emitStream(ev)
+ .pipe(JSONStream.stringify())
+ .pipe(stream)
+ ;
});
})();
server.listen(5555);

0 comments on commit 20d6e4e

Please sign in to comment.
Something went wrong with that request. Please try again.