Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vernemq
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
stack
vernemq
Commits
569251f8
Commit
569251f8
authored
Nov 19, 2018
by
zCaesar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix count device
parent
b0008ed3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
10 deletions
+14
-10
authhook/redis/on_offline.js
+7
-5
authhook/redis/on_register.js
+7
-5
No files found.
authhook/redis/on_offline.js
View file @
569251f8
...
...
@@ -8,10 +8,9 @@ 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
)
{
resolve
(
!
res
)
// 0 is ok, 1 is no => if ok is 0 then not 0 = 1
})
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
authhook/redis/on_register.js
View file @
569251f8
...
...
@@ -9,10 +9,9 @@ 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
)
{
resolve
(
!
res
)
// 0 is ok, 1 is no => if ok is 0 then not 0 = 1
})
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment