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
e46d316b
Commit
e46d316b
authored
Nov 19, 2018
by
zCaesar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check realtime db redis on msg
parent
16b4635d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
12 deletions
+18
-12
authhook/redis/on_message.js
+18
-12
No files found.
authhook/redis/on_message.js
View file @
e46d316b
...
@@ -3,18 +3,24 @@ var redis = new Redis()
...
@@ -3,18 +3,24 @@ var redis = new Redis()
function
on_message_redis
(
deviceid
,
payload
)
{
// first time to access on authhook auth_on_register
function
on_message_redis
(
deviceid
,
payload
)
{
// first time to access on authhook auth_on_register
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
var
information
=
setValue
(
deviceid
,
payload
)
if
(
deviceid
.
indexOf
(
'mqtt'
)
===
0
&&
deviceid
.
length
!==
36
)
{
redis
.
hincrby
(
information
.
keys
,
'actual_message_count'
,
1
)
console
.
log
(
deviceid
)
redis
.
hincrby
(
information
.
keys
,
'charged_message_count'
,
information
.
charged_message_count
)
resolve
(
true
)
redis
.
hincrby
(
information
.
keys
,
'total_message_size'
,
information
.
total_message_size
)
}
else
{
redis
.
hincrby
(
setBrokerValue
().
keys
,
'actual_message_count'
,
1
)
var
information
=
setValue
(
deviceid
,
payload
)
redis
.
hincrby
(
setBrokerValue
().
keys
,
'charged_message_count'
,
information
.
charged_message_count
)
redis
.
hincrby
(
information
.
keys
,
'actual_message_count'
,
1
)
redis
.
hincrby
(
setBrokerValue
().
keys
,
'total_message_size'
,
information
.
total_message_size
)
redis
.
hincrby
(
information
.
keys
,
'charged_message_count'
,
information
.
charged_message_count
)
redis
.
hincrby
(
information
.
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
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
})
}
})
})
}
}
module
.
exports
.
on_message_redis
=
on_message_redis
module
.
exports
.
on_message_redis
=
on_message_redis
...
...
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