Permalink
Browse files

add devent-zmq writer

  • Loading branch information...
dchester committed Aug 25, 2012
1 parent 10946a9 commit a94ce7221cde4e01a07a06e8b3fb6b85c55bfea2
Showing with 30 additions and 0 deletions.
  1. +27 −0 lib/writers/devent-zmq.js
  2. +3 −0 package.json
View
@@ -0,0 +1,27 @@
+var zmq = require('zmq');
+var util = require('util');
+
+var DeventZMQWriter = function(options) {
+
+ events.EventEmitter.call(this);
+
+ var uri = 'tcp://' + [options['devent-host'], options['devent-port']].join(':');
+
+ this.socket = zmq.socket('push');
+ this.socket.bindSync(uri);
+
+ this.on('data', function(data) {
+
+ this.socket.send(options['devent-topic'], zmq.ZMQ_SNDMORE);
+ this.socket.send(JSON.stringify(data));
+ });
+
+ this.on('close', function() {
+ this.socket.close();
+ });
+};
+
+util.inherits(DeventZMQWriter, events.EventEmitter);
+
+module.exports = DeventZMQWriter;
+
View
@@ -2,6 +2,9 @@
"name": "lil-brother"
, "version": "0.0.1"
, "private": true
+ , "optionalDependencies": {
+ "zmq": "= 2.0.0"
+ }
, "dependencies": {
"nomnom": "> 1.x.x",
"uglify-js": "> 1.x.x"

0 comments on commit a94ce72

Please sign in to comment.