diff --git a/lib/server.js b/lib/server.js index fcae99e..8ea4b36 100755 --- a/lib/server.js +++ b/lib/server.js @@ -262,8 +262,8 @@ function Server(opts, callback) { ); }); - that.on("subscribed", function(topic, client) { - if(that.modernOpts.publishSubscriptions) { + if(that.modernOpts.publishSubscriptions) { + that.on("subscribed", function(topic, client) { that.publish({ topic: "$SYS/" + that.id + "/new/subscribes", payload: JSON.stringify({ @@ -271,11 +271,9 @@ function Server(opts, callback) { topic: topic }) }); - } - }); + }); - that.on("unsubscribed", function(topic, client) { - if(that.modernOpts.publishSubscriptions) { + that.on("unsubscribed", function(topic, client) { that.publish({ topic: "$SYS/" + that.id + "/new/unsubscribes", payload: JSON.stringify({ @@ -283,8 +281,8 @@ function Server(opts, callback) { topic: topic }) }); - } - }); + }); + } that.on("clientDisconnected", function(client) { if(that.modernOpts.publishClientDisconnect) {