diff --git a/lib/zeromq_ascoltatore.js b/lib/zeromq_ascoltatore.js index 5c12689..922593e 100644 --- a/lib/zeromq_ascoltatore.js +++ b/lib/zeromq_ascoltatore.js @@ -34,12 +34,12 @@ function ZeromqAscoltatore(opts) { this._opts.delay = this._opts.delay || 5; this._opts.zmq = this._opts.zmq || require("zmq"); + this._connectedControls = []; + this._ascoltatore = new TrieAscoltatore(opts); this._startSubs(); this._startPub(); this._startControl(); - - this._connectedControls = []; } /** @@ -122,8 +122,13 @@ ZeromqAscoltatore.prototype._startControl = function() { }, 250); that._control_conn.on("message", function(data) { - debug("received connect response from " + data); - that._connectSub(data); + var dest = String(data) + debug("received connect response from " + dest); + if (that._sub_conns.findIndex(function (conn) { + return conn.port === dest; + }) === -1) { + that._connectSub(dest); + } }); }); }