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
af9c7f40
Commit
af9c7f40
authored
Nov 20, 2018
by
zCaesar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix status
parent
276abdc1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
18 deletions
+32
-18
authhook/auth_on_register.js
+18
-8
authhook/on_offline.js
+1
-2
authhook/redis/on_offline.js
+7
-4
authhook/redis/on_register.js
+6
-4
No files found.
authhook/auth_on_register.js
View file @
af9c7f40
...
...
@@ -107,10 +107,15 @@ module.exports = function (options = {}) {
if
(
result
)
{
require
(
'./redis/on_register'
).
on_register_redis
(
req
.
body
.
client_id
).
then
(
status
=>
{
console
.
log
(
'redis:status: '
+
status
)
require
(
'./redis/on_register'
).
deviceUsageCount
()
res
.
send
({
"result"
:
status
?
"ok"
:
"no"
});
if
(
status
)
{
res
.
send
({
"result"
:
"ok"
});
}
else
{
res
.
send
({
"result"
:
"no"
});
}
})
}
else
{
res
.
send
({
...
...
@@ -125,10 +130,15 @@ module.exports = function (options = {}) {
if
(
authstatus
)
{
require
(
'./redis/on_register'
).
on_register_redis
(
req
.
body
.
client_id
).
then
(
status
=>
{
console
.
log
(
'redis:status: '
+
status
)
require
(
'./redis/on_register'
).
deviceUsageCount
()
res
.
send
({
"result"
:
status
?
"ok"
:
"no"
});
if
(
status
)
{
res
.
send
({
"result"
:
"ok"
});
}
else
{
res
.
send
({
"result"
:
"no"
});
}
})
}
else
{
res
.
send
({
...
...
authhook/on_offline.js
View file @
af9c7f40
module
.
exports
=
function
(
options
=
{})
{
module
.
exports
=
function
(
options
=
{})
{
debug
=
options
.
debug
||
false
;
...
...
@@ -10,7 +10,6 @@ module.exports = function(options = {}) {
function
doRedis
(
client_id
)
{
if
(
client_id
.
indexOf
(
'mqttjs'
)
===
-
1
)
{
require
(
'./redis/on_offline'
).
on_offline_redis
(
client_id
).
then
(
status
=>
{
require
(
'./redis/on_offline'
).
deviceUsageCount
()
console
.
log
(
'redis:status: '
+
status
)
})
}
...
...
authhook/redis/on_offline.js
View file @
af9c7f40
...
...
@@ -9,7 +9,11 @@ function on_offline_redis(deviceid) { // first time to access on authhook auth_o
else
{
var
information
=
setValue
(
deviceid
)
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
console
.
log
(
res
)
if
(
res
)
{
deviceUsageCount
()
resolve
(
!
res
)
// 0 is ok, 1 is no => if ok is 0 then not 0 = 1
}
else
resolve
(
!
res
)
})
}
})
...
...
@@ -31,5 +35,4 @@ function setValue(deviceid) {
function
deviceUsageCount
()
{
console
.
log
(
'device_usage_offline'
)
redis
.
hincrby
(
'_broker:1'
,
'device_online'
,
-
1
)
}
module
.
exports
.
deviceUsageCount
=
deviceUsageCount
\ No newline at end of file
}
\ No newline at end of file
authhook/redis/on_register.js
View file @
af9c7f40
...
...
@@ -10,7 +10,10 @@ function on_register_redis(deviceid) { // first time to access on authhook auth_
var
information
=
setValue
(
deviceid
)
redis
.
hdel
(
information
.
keys
,
'offline_on'
)
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
if
(
!
res
)
{
deviceUsageCount
()
resolve
(
!
res
)
// 0 is ok, 1 is no => if ok is 0 then not 0 = 1
}
else
resolve
(
!
res
)
})
}
})
...
...
@@ -34,5 +37,4 @@ function setValue(deviceid) {
function
deviceUsageCount
()
{
console
.
log
(
'device_usage_online'
)
redis
.
hincrby
(
'_broker:1'
,
'device_online'
,
1
)
}
module
.
exports
.
deviceUsageCount
=
deviceUsageCount
\ No newline at end of file
}
\ 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