Commit b6ebba90 by zCaesar

fix bug redis

parent 45d6b5ff
var config = require('config');
// 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"),
cache = LRU({
max: 500,
......
......@@ -3,7 +3,7 @@ var validator = require('./validator');
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('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
var LRU = require("lru-cache"),
......
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 = {}) {
......
......@@ -11,7 +11,8 @@ function on_message_redis(deviceid, payload, topic) { // first time to access on
let information = setValue(deviceid, payload, topic)
let luafile = path.join(__dirname, '/on_message.lua')
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', {
numberOfKeys: 2,
......@@ -21,8 +22,8 @@ function on_message_redis(deviceid, payload, topic) { // first time to access on
let device_keys = information.keys
let broker_keys = '_broker:1'
let last_publish = information.last_publish
let charged_message_count = information.charged_message_count
let total_message_size = information.total_message_size
let charged_message_count = Math.floor(information.charged_message_count)
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) => {
if (err) console.log(err)
......
......@@ -11,8 +11,9 @@ function on_offline_redis(deviceid) { // first time to access on authhook auth_o
let information = setValue(deviceid)
let luafile = path.join(__dirname, '/on_offline.lua')
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', {
numberOfKeys: 2,
lua: luastring
......
......@@ -11,8 +11,9 @@ function on_register_redis(deviceid) { // first time to access on authhook auth_
var information = setValue(deviceid)
let luafile = path.join(__dirname, '/on_register.lua')
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', {
numberOfKeys: 2,
lua: luastring
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment