Commit e46d316b by zCaesar

check realtime db redis on msg

parent 16b4635d
......@@ -3,18 +3,24 @@ var redis = new Redis()
function on_message_redis(deviceid, payload) { // first time to access on authhook auth_on_register
return new Promise((resolve, reject) => {
var information = setValue(deviceid, payload)
redis.hincrby(information.keys, 'actual_message_count', 1)
redis.hincrby(information.keys, 'charged_message_count', information.charged_message_count)
redis.hincrby(information.keys, 'total_message_size', information.total_message_size)
redis.hincrby(setBrokerValue().keys, 'actual_message_count', 1)
redis.hincrby(setBrokerValue().keys, 'charged_message_count', information.charged_message_count)
redis.hincrby(setBrokerValue().keys, 'total_message_size', information.total_message_size)
redis.hset(information.keys, 'last_publish', information.last_publish, function (err, res) {
resolve(!res) // 0 is ok, 1 is no => if ok is 0 then not 0 = 1
})
if (deviceid.indexOf('mqtt') === 0 && deviceid.length !== 36) {
console.log(deviceid)
resolve(true)
}
else {
var information = setValue(deviceid, payload)
redis.hincrby(information.keys, 'actual_message_count', 1)
redis.hincrby(information.keys, 'charged_message_count', information.charged_message_count)
redis.hincrby(information.keys, 'total_message_size', information.total_message_size)
redis.hincrby(setBrokerValue().keys, 'actual_message_count', 1)
redis.hincrby(setBrokerValue().keys, 'charged_message_count', information.charged_message_count)
redis.hincrby(setBrokerValue().keys, 'total_message_size', information.total_message_size)
redis.hset(information.keys, 'last_publish', information.last_publish, function (err, res) {
resolve(!res) // 0 is ok, 1 is no => if ok is 0 then not 0 = 1
})
}
})
}
module.exports.on_message_redis = on_message_redis
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment