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
b6ebba90
Commit
b6ebba90
authored
Dec 11, 2018
by
zCaesar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug redis
parent
45d6b5ff
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
11 additions
and
8 deletions
+11
-8
authhook/auth_on_publish.js
+1
-1
authhook/auth_on_register.js
+1
-1
authhook/on_offline.js
+1
-1
authhook/redis-atomic/on_message.js
+4
-3
authhook/redis-atomic/on_offline.js
+2
-1
authhook/redis-atomic/on_register.js
+2
-1
No files found.
authhook/auth_on_publish.js
View file @
b6ebba90
var
config
=
require
(
'config'
);
var
config
=
require
(
'config'
);
// https://github.com/isaacs/node-lru-cache
// https://github.com/isaacs/node-lru-cache
var
on_message_redis
=
require
(
'./redis/on_message'
).
on_message_redis
var
on_message_redis
=
require
(
'./redis
-atomic
/on_message'
).
on_message_redis
var
LRU
=
require
(
"lru-cache"
),
var
LRU
=
require
(
"lru-cache"
),
cache
=
LRU
({
cache
=
LRU
({
max
:
500
,
max
:
500
,
...
...
authhook/auth_on_register.js
View file @
b6ebba90
...
@@ -3,7 +3,7 @@ var validator = require('./validator');
...
@@ -3,7 +3,7 @@ var validator = require('./validator');
var
config
=
require
(
'config'
);
var
config
=
require
(
'config'
);
// var seneca = require('seneca')({log: 'silent'}).client({ port: config.get('device_registry_port'), host: config.get('device_registry_host') });
// var seneca = require('seneca')({log: 'silent'}).client({ port: config.get('device_registry_port'), host: config.get('device_registry_host') });
var
seneca
=
require
(
'seneca'
)({
log
:
'silent'
}).
client
({
port
:
config
.
get
(
'token_registry_port'
),
host
:
config
.
get
(
'token_registry_host'
)
});
var
seneca
=
require
(
'seneca'
)({
log
:
'silent'
}).
client
({
port
:
config
.
get
(
'token_registry_port'
),
host
:
config
.
get
(
'token_registry_host'
)
});
var
on_register_redis
=
require
(
'./redis/on_register'
).
on_register_redis
var
on_register_redis
=
require
(
'./redis
-atomic
/on_register'
).
on_register_redis
// https://github.com/isaacs/node-lru-cache
// https://github.com/isaacs/node-lru-cache
var
LRU
=
require
(
"lru-cache"
),
var
LRU
=
require
(
"lru-cache"
),
...
...
authhook/on_offline.js
View file @
b6ebba90
var
on_offline_redis
=
require
(
'./redis/on_offline'
).
on_offline_redis
var
on_offline_redis
=
require
(
'./redis
-atomic
/on_offline'
).
on_offline_redis
module
.
exports
=
function
(
options
=
{})
{
module
.
exports
=
function
(
options
=
{})
{
...
...
authhook/redis-atomic/on_message.js
View file @
b6ebba90
...
@@ -11,7 +11,8 @@ function on_message_redis(deviceid, payload, topic) { // first time to access on
...
@@ -11,7 +11,8 @@ function on_message_redis(deviceid, payload, topic) { // first time to access on
let
information
=
setValue
(
deviceid
,
payload
,
topic
)
let
information
=
setValue
(
deviceid
,
payload
,
topic
)
let
luafile
=
path
.
join
(
__dirname
,
'/on_message.lua'
)
let
luafile
=
path
.
join
(
__dirname
,
'/on_message.lua'
)
let
file
=
fs
.
readFileSync
(
luafile
)
let
file
=
fs
.
readFileSync
(
luafile
)
let
luastring
=
Buffer
.
from
(
JSON
.
parse
(
JSON
.
stringify
(
file
)).
data
).
toString
(
'utf8'
)
// let luastring = Buffer.from(JSON.parse(JSON.stringify(file)).data).toString('utf8')
let
luastring
=
fs
.
readFileSync
(
luafile
,
'utf8'
)
redis
.
defineCommand
(
'on_message'
,
{
redis
.
defineCommand
(
'on_message'
,
{
numberOfKeys
:
2
,
numberOfKeys
:
2
,
...
@@ -21,8 +22,8 @@ function on_message_redis(deviceid, payload, topic) { // first time to access on
...
@@ -21,8 +22,8 @@ function on_message_redis(deviceid, payload, topic) { // first time to access on
let
device_keys
=
information
.
keys
let
device_keys
=
information
.
keys
let
broker_keys
=
'_broker:1'
let
broker_keys
=
'_broker:1'
let
last_publish
=
information
.
last_publish
let
last_publish
=
information
.
last_publish
let
charged_message_count
=
information
.
charged_message_count
let
charged_message_count
=
Math
.
floor
(
information
.
charged_message_count
)
let
total_message_size
=
information
.
total_message_size
let
total_message_size
=
Math
.
floor
(
information
.
total_message_size
)
redis
.
on_message
(
device_keys
,
broker_keys
,
charged_message_count
,
total_message_size
,
last_publish
,
(
err
,
result
)
=>
{
redis
.
on_message
(
device_keys
,
broker_keys
,
charged_message_count
,
total_message_size
,
last_publish
,
(
err
,
result
)
=>
{
if
(
err
)
console
.
log
(
err
)
if
(
err
)
console
.
log
(
err
)
...
...
authhook/redis-atomic/on_offline.js
View file @
b6ebba90
...
@@ -11,7 +11,8 @@ function on_offline_redis(deviceid) { // first time to access on authhook auth_o
...
@@ -11,7 +11,8 @@ function on_offline_redis(deviceid) { // first time to access on authhook auth_o
let
information
=
setValue
(
deviceid
)
let
information
=
setValue
(
deviceid
)
let
luafile
=
path
.
join
(
__dirname
,
'/on_offline.lua'
)
let
luafile
=
path
.
join
(
__dirname
,
'/on_offline.lua'
)
let
file
=
fs
.
readFileSync
(
luafile
)
let
file
=
fs
.
readFileSync
(
luafile
)
let
luastring
=
Buffer
.
from
(
JSON
.
parse
(
JSON
.
stringify
(
file
)).
data
).
toString
(
'utf8'
)
// let luastring = Buffer.from(JSON.parse(JSON.stringify(file)).data).toString('utf8')
let
luastring
=
fs
.
readFileSync
(
luafile
,
'utf8'
)
redis
.
defineCommand
(
'on_offline'
,
{
redis
.
defineCommand
(
'on_offline'
,
{
numberOfKeys
:
2
,
numberOfKeys
:
2
,
...
...
authhook/redis-atomic/on_register.js
View file @
b6ebba90
...
@@ -11,7 +11,8 @@ function on_register_redis(deviceid) { // first time to access on authhook auth_
...
@@ -11,7 +11,8 @@ function on_register_redis(deviceid) { // first time to access on authhook auth_
var
information
=
setValue
(
deviceid
)
var
information
=
setValue
(
deviceid
)
let
luafile
=
path
.
join
(
__dirname
,
'/on_register.lua'
)
let
luafile
=
path
.
join
(
__dirname
,
'/on_register.lua'
)
let
file
=
fs
.
readFileSync
(
luafile
)
let
file
=
fs
.
readFileSync
(
luafile
)
let
luastring
=
Buffer
.
from
(
JSON
.
parse
(
JSON
.
stringify
(
file
)).
data
).
toString
(
'utf8'
)
// let luastring = Buffer.from(JSON.parse(JSON.stringify(file)).data).toString('utf8')
let
luastring
=
fs
.
readFileSync
(
luafile
,
'utf8'
)
redis
.
defineCommand
(
'on_register'
,
{
redis
.
defineCommand
(
'on_register'
,
{
numberOfKeys
:
2
,
numberOfKeys
:
2
,
...
...
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