Commit 569251f8 by zCaesar

fix count device

parent b0008ed3
......@@ -8,11 +8,10 @@ function on_offline_redis(deviceid) { // first time to access on authhook auth_o
}
else {
var information = setValue(deviceid)
redis.hincrby(setBrokerValue().keys, 'device_usage_count', -1, function (err, res) {
redis.hset(information.keys, 'status', information.status, 'offline_on', information.offline_on, function (err, res) {
redis.hset(setBrokerValue().keys, 'device_client_count', setBrokerValue().device_client_count)
resolve(!res) // 0 is ok, 1 is no => if ok is 0 then not 0 = 1
})
})
}
})
}
......@@ -32,7 +31,9 @@ function setValue(deviceid) {
function setBrokerValue() {
var keys = '_broker:1'
var device_client_count = redis.dbsize() - 1
return {
keys: keys
keys: keys,
device_client_count: device_client_count
}
}
\ No newline at end of file
......@@ -9,11 +9,10 @@ function on_register_redis(deviceid) { // first time to access on authhook auth_
else {
var information = setValue(deviceid)
redis.hdel(information.keys, 'offline_on')
redis.hincrby(setBrokerValue().keys, 'device_usage_count', 1, function (err, res) {
redis.hset(information.keys, 'status', information.status, 'register_on', information.register_on, 'last_check', information.last_check, function (err, res) {
redis.hset(setBrokerValue().keys, 'device_client_count', setBrokerValue().device_client_count)
resolve(!res) // 0 is ok, 1 is no => if ok is 0 then not 0 = 1
})
})
}
})
}
......@@ -35,7 +34,9 @@ function setValue(deviceid) {
function setBrokerValue() {
var keys = '_broker:1'
var device_client_count = redis.dbsize() - 1
return {
keys: keys
keys: keys,
device_client_count: device_client_count
}
}
\ No newline at end of file
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