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
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
10 deletions
+24
-10
authhook/auth_on_register.js
+14
-4
authhook/on_offline.js
+1
-2
authhook/redis/on_offline.js
+5
-2
authhook/redis/on_register.js
+4
-2
No files found.
authhook/auth_on_register.js
View file @
af9c7f40
...
@@ -107,10 +107,15 @@ module.exports = function (options = {}) {
...
@@ -107,10 +107,15 @@ module.exports = function (options = {}) {
if
(
result
)
{
if
(
result
)
{
require
(
'./redis/on_register'
).
on_register_redis
(
req
.
body
.
client_id
).
then
(
status
=>
{
require
(
'./redis/on_register'
).
on_register_redis
(
req
.
body
.
client_id
).
then
(
status
=>
{
console
.
log
(
'redis:status: '
+
status
)
console
.
log
(
'redis:status: '
+
status
)
require
(
'./redis/on_register'
).
deviceUsageCount
()
if
(
status
)
{
res
.
send
({
res
.
send
({
"result"
:
status
?
"ok"
:
"no
"
"result"
:
"ok
"
});
});
}
else
{
res
.
send
({
"result"
:
"no"
});
}
})
})
}
else
{
}
else
{
res
.
send
({
res
.
send
({
...
@@ -125,10 +130,15 @@ module.exports = function (options = {}) {
...
@@ -125,10 +130,15 @@ module.exports = function (options = {}) {
if
(
authstatus
)
{
if
(
authstatus
)
{
require
(
'./redis/on_register'
).
on_register_redis
(
req
.
body
.
client_id
).
then
(
status
=>
{
require
(
'./redis/on_register'
).
on_register_redis
(
req
.
body
.
client_id
).
then
(
status
=>
{
console
.
log
(
'redis:status: '
+
status
)
console
.
log
(
'redis:status: '
+
status
)
require
(
'./redis/on_register'
).
deviceUsageCount
()
if
(
status
)
{
res
.
send
({
res
.
send
({
"result"
:
status
?
"ok"
:
"no
"
"result"
:
"ok
"
});
});
}
else
{
res
.
send
({
"result"
:
"no"
});
}
})
})
}
else
{
}
else
{
res
.
send
({
res
.
send
({
...
...
authhook/on_offline.js
View file @
af9c7f40
module
.
exports
=
function
(
options
=
{})
{
module
.
exports
=
function
(
options
=
{})
{
debug
=
options
.
debug
||
false
;
debug
=
options
.
debug
||
false
;
...
@@ -10,7 +10,6 @@ module.exports = function(options = {}) {
...
@@ -10,7 +10,6 @@ module.exports = function(options = {}) {
function
doRedis
(
client_id
)
{
function
doRedis
(
client_id
)
{
if
(
client_id
.
indexOf
(
'mqttjs'
)
===
-
1
)
{
if
(
client_id
.
indexOf
(
'mqttjs'
)
===
-
1
)
{
require
(
'./redis/on_offline'
).
on_offline_redis
(
client_id
).
then
(
status
=>
{
require
(
'./redis/on_offline'
).
on_offline_redis
(
client_id
).
then
(
status
=>
{
require
(
'./redis/on_offline'
).
deviceUsageCount
()
console
.
log
(
'redis:status: '
+
status
)
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
...
@@ -9,7 +9,11 @@ function on_offline_redis(deviceid) { // first time to access on authhook auth_o
else
{
else
{
var
information
=
setValue
(
deviceid
)
var
information
=
setValue
(
deviceid
)
redis
.
hset
(
information
.
keys
,
'status'
,
information
.
status
,
'offline_on'
,
information
.
offline_on
,
function
(
err
,
res
)
{
redis
.
hset
(
information
.
keys
,
'status'
,
information
.
status
,
'offline_on'
,
information
.
offline_on
,
function
(
err
,
res
)
{
console
.
log
(
res
)
if
(
res
)
{
deviceUsageCount
()
resolve
(
!
res
)
// 0 is ok, 1 is no => if ok is 0 then not 0 = 1
resolve
(
!
res
)
// 0 is ok, 1 is no => if ok is 0 then not 0 = 1
}
else
resolve
(
!
res
)
})
})
}
}
})
})
...
@@ -32,4 +36,3 @@ function deviceUsageCount() {
...
@@ -32,4 +36,3 @@ function deviceUsageCount() {
console
.
log
(
'device_usage_offline'
)
console
.
log
(
'device_usage_offline'
)
redis
.
hincrby
(
'_broker:1'
,
'device_online'
,
-
1
)
redis
.
hincrby
(
'_broker:1'
,
'device_online'
,
-
1
)
}
}
\ No newline at end of file
module
.
exports
.
deviceUsageCount
=
deviceUsageCount
\ 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_
...
@@ -10,7 +10,10 @@ function on_register_redis(deviceid) { // first time to access on authhook auth_
var
information
=
setValue
(
deviceid
)
var
information
=
setValue
(
deviceid
)
redis
.
hdel
(
information
.
keys
,
'offline_on'
)
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
)
{
redis
.
hset
(
information
.
keys
,
'status'
,
information
.
status
,
'register_on'
,
information
.
register_on
,
'last_check'
,
information
.
last_check
,
function
(
err
,
res
)
{
if
(
!
res
)
{
deviceUsageCount
()
resolve
(
!
res
)
// 0 is ok, 1 is no => if ok is 0 then not 0 = 1
resolve
(
!
res
)
// 0 is ok, 1 is no => if ok is 0 then not 0 = 1
}
else
resolve
(
!
res
)
})
})
}
}
})
})
...
@@ -35,4 +38,3 @@ function deviceUsageCount() {
...
@@ -35,4 +38,3 @@ function deviceUsageCount() {
console
.
log
(
'device_usage_online'
)
console
.
log
(
'device_usage_online'
)
redis
.
hincrby
(
'_broker:1'
,
'device_online'
,
1
)
redis
.
hincrby
(
'_broker:1'
,
'device_online'
,
1
)
}
}
\ No newline at end of file
module
.
exports
.
deviceUsageCount
=
deviceUsageCount
\ 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