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
a328920c
Commit
a328920c
authored
Nov 19, 2018
by
zCaesar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add broker count and fixed onoff
parent
daabfd9d
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
3 deletions
+34
-3
authhook/auth_on_register.js
+2
-2
authhook/on_offline.js
+1
-1
authhook/redis/on_message.js
+13
-0
authhook/redis/on_offline.js
+9
-0
authhook/redis/on_register.js
+9
-0
No files found.
authhook/auth_on_register.js
View file @
a328920c
...
...
@@ -106,7 +106,7 @@ module.exports = function (options = {}) {
cache
.
set
(
cachekey
,
result
);
console
.
log
(
client_id
)
console
.
log
(
client_id
.
indexOf
(
'-'
))
if
(
client_id
.
indexOf
(
'mqttjs
_
'
)
!==
-
1
)
{
if
(
client_id
.
indexOf
(
'mqttjs'
)
!==
-
1
)
{
res
.
send
({
"result"
:
result
?
"ok"
:
"no"
});
...
...
@@ -124,7 +124,7 @@ module.exports = function (options = {}) {
});
}
else
{
if
(
client_id
.
indexOf
(
'mqttjs
_
'
)
!==
-
1
)
{
if
(
client_id
.
indexOf
(
'mqttjs'
)
!==
-
1
)
{
res
.
send
({
"result"
:
authstatus
?
"ok"
:
"no"
});
...
...
authhook/on_offline.js
View file @
a328920c
...
...
@@ -7,7 +7,7 @@ module.exports = function(options = {}) {
}
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
=>
{
console
.
log
(
'redis:status: '
+
status
)
})
...
...
authhook/redis/on_message.js
View file @
a328920c
...
...
@@ -7,6 +7,11 @@ function on_message_redis(deviceid, payload) { // first time to access on authho
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
})
...
...
@@ -32,3 +37,10 @@ function setValue(deviceid, payload) {
total_message_size
:
total_message_size
}
}
function
setBrokerValue
()
{
var
keys
=
'_broker:1'
return
{
keys
:
keys
}
}
\ No newline at end of file
authhook/redis/on_offline.js
View file @
a328920c
...
...
@@ -4,6 +4,7 @@ var redis = new Redis()
function
on_offline_redis
(
deviceid
)
{
// first time to access on authhook auth_on_register
return
new
Promise
((
resolve
,
reject
)
=>
{
var
information
=
setValue
(
deviceid
)
redis
.
hincrby
(
setBrokerValue
().
keys
,
'device_usage_count'
,
-
1
)
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
})
...
...
@@ -22,3 +23,10 @@ function setValue(deviceid) {
offline_on
:
offline_on
}
}
function
setBrokerValue
()
{
var
keys
=
'_broker:1'
return
{
keys
:
keys
}
}
\ No newline at end of file
authhook/redis/on_register.js
View file @
a328920c
...
...
@@ -5,6 +5,7 @@ function on_register_redis(deviceid) { // first time to access on authhook auth_
return
new
Promise
((
resolve
,
reject
)
=>
{
var
information
=
setValue
(
deviceid
)
redis
.
hdel
(
information
.
keys
,
'offline_on'
)
redis
.
hincrby
(
setBrokerValue
().
keys
,
'device_usage_count'
,
1
)
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
})
...
...
@@ -25,3 +26,10 @@ function setValue(deviceid) {
last_check
:
last_check
}
}
function
setBrokerValue
()
{
var
keys
=
'_broker:1'
return
{
keys
:
keys
}
}
\ 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