From 04ce1800ada4f966beba59c389ab12e82061d023 Mon Sep 17 00:00:00 2001 From: 沈斌 <bluelazysb@hotmail.com> Date: Sun, 25 Dec 2016 21:27:27 +0800 Subject: [PATCH] 添加监听代码以便实时修改通讯配置 --- server.js | 25 +++++++++++++++++-------- 1 files changed, 17 insertions(+), 8 deletions(-) diff --git a/server.js b/server.js index 8154945..921b518 100644 --- a/server.js +++ b/server.js @@ -10,16 +10,19 @@ var queue = require('./queue'); var map = { - "5a0000010001": 32, - "5a0000010002": 102, - "5a0000010003": 162, - "5a0000010004": 32, - "5a0000010006": 122, - "5a0000010007": 32, - "5a000001000c": 20 + "5a0000010001": 32, //��������������� + "5a0000010002": 102, //���������������WIFI������ + "5a0000010003": 162, //��������������������� + "5a0000010004": 32, //������������ + "5a0000010006": 122, //������������ + "5a0000010007": 32, //������������������������������������������ + "5a000001000c": 20 //������������ }; +global.configs = {}; + function handleData(db, socket, value) { + //1.��������������� if(value.startsWith('5a0000010001')) { var output = [ 0x6A, 0x00, 0x00, 0x01, 0x00, 0x01, 0xA1, 0x1A, 0xC7, 0x6B ]; @@ -118,6 +121,12 @@ } console.log('Connecting to Mongo DB at ' + config.URL); + //��������������������������������� + method.initConfigs(db); + + //��������������������������������������� + queue.listenToMQ("ex_data_config"); + net.createServer().on('connection', function(socket){ console.log('CONNECTED: ' + socket.remoteAddress +':'+ socket.remotePort); @@ -157,4 +166,4 @@ }).listen(config.PORT, config.HOST); console.log('TCP Server listening on ' + config.HOST + ':' + config.PORT); -}); +}); \ No newline at end of file -- Gitblit v1.8.0