From e4f5a1dbc596492c8181234f00ef45b875ebc07f Mon Sep 17 00:00:00 2001 From: 沈斌 <bluelazysb@hotmail.com> Date: Fri, 23 Dec 2016 21:47:35 +0800 Subject: [PATCH] 服务端判断pm2.5>500发送警报指令 --- queue.js | 31 ++++++++++++++++++++++++++++++- 1 files changed, 30 insertions(+), 1 deletions(-) diff --git a/queue.js b/queue.js index 0d55a18..b136fbb 100644 --- a/queue.js +++ b/queue.js @@ -15,6 +15,35 @@ var message = '{"data": "' + data + '", "time":"' + moment().format('YYYY-MM-DD HH:mm:ss') + '"}'; ch.publish(ex, '', new Buffer(message)); }); - setTimeout(function() { conn.close(); process.exit(0) }, 500); + setTimeout(function() { + conn.close(); + //process.exit(0) + }, 500); + }); +}; + +module.exports.pushToScreen = function(data) { + amqp.connect(uri, function(err, conn) { + conn.createChannel(function(err, ch) { + var _ex = 'ex_data_screen'; + ch.assertExchange(_ex, 'fanout', { durable: false }); + ch.publish(_ex, '', new Buffer(JSON.stringify(data))); + }); + setTimeout(function() { + conn.close(); + }, 500); + }); +}; + +module.exports.pushToAlarm = function(data) { + amqp.connect(uri, function(err, conn) { + conn.createChannel(function(err, ch) { + var _ex = 'ex_data_alarm'; + ch.assertExchange(_ex, 'fanout', { durable: false }); + ch.publish(_ex, '', new Buffer(JSON.stringify(data))); + }); + setTimeout(function() { + conn.close(); + }, 500); }); }; \ No newline at end of file -- Gitblit v1.8.0