Commit 12906759 by zCaesar

add offline

parent ff76f879
...@@ -27,7 +27,7 @@ function authCheck(client_id, token, password, callback) { ...@@ -27,7 +27,7 @@ function authCheck(client_id, token, password, callback) {
} }
else { else {
// console.log('token :' + token) console.log('token :' + token)
seneca.act('ms:tokenregistry, cmd:getAttributes, type:device, tokencode:' + token, function (err, res) { seneca.act('ms:tokenregistry, cmd:getAttributes, type:device, tokencode:' + token, function (err, res) {
// console.log('result : ' + util.inspect(res.result, false, null, true)) // console.log('result : ' + util.inspect(res.result, false, null, true))
if (res.result) { if (res.result) {
...@@ -37,7 +37,7 @@ function authCheck(client_id, token, password, callback) { ...@@ -37,7 +37,7 @@ function authCheck(client_id, token, password, callback) {
token: token, token: token,
password: password password: password
}; };
callback(validator.auth_connect(mqttauth, token_profile).status); callback(validator.auth_connect(mqttauth, token_profile));
} }
else { else {
callback(false); callback(false);
......
...@@ -13,5 +13,6 @@ ...@@ -13,5 +13,6 @@
"auth_on_subscribe_debug" : "AUTH_ON_SUBSCRIBE_DEBUG", "auth_on_subscribe_debug" : "AUTH_ON_SUBSCRIBE_DEBUG",
"on_publish_debug" : "ON_PUBLISH_DEBUG", "on_publish_debug" : "ON_PUBLISH_DEBUG",
"on_deliver_debug" : "ON_DELIVER_DEBUG", "on_deliver_debug" : "ON_DELIVER_DEBUG",
"on_unsubscribe_debug" : "ON_UNSUBSCRIBE_DEBUG" "on_unsubscribe_debug" : "ON_UNSUBSCRIBE_DEBUG",
"on_offline_debug" : "ON_OFFLINE_DEBUG"
} }
\ No newline at end of file
...@@ -7,5 +7,6 @@ ...@@ -7,5 +7,6 @@
"auth_on_subscribe_debug" : false, "auth_on_subscribe_debug" : false,
"on_publish_debug" : false, "on_publish_debug" : false,
"on_deliver_debug" : false, "on_deliver_debug" : false,
"on_unsubscribe_debug" : false "on_unsubscribe_debug" : false,
"on_offline_debug" : false
} }
{ {
"device_registry_host" : "localhost", "device_registry_host" : "alpha.nexpie.io",
"device_registry_port" : 8990, "device_registry_port" : 8990,
"token_registry_host" : "localhost", "token_registry_host" : "alpha.nexpie.io",
"token_registry_port" : 8790, "token_registry_port" : 8790,
"auth_on_register_debug" : true, "auth_on_register_debug" : true,
...@@ -10,5 +10,6 @@ ...@@ -10,5 +10,6 @@
"auth_on_subscribe_debug" : true, "auth_on_subscribe_debug" : true,
"on_publish_debug" : true, "on_publish_debug" : true,
"on_deliver_debug" : true, "on_deliver_debug" : true,
"on_unsubscribe_debug" : true "on_unsubscribe_debug" : true,
"on_offline_debug" : true
} }
...@@ -7,6 +7,7 @@ var auth_on_subscribe_debug = config.get('auth_on_subscribe_debug'); ...@@ -7,6 +7,7 @@ var auth_on_subscribe_debug = config.get('auth_on_subscribe_debug');
var on_publish_debug = config.get('on_publish_debug'); var on_publish_debug = config.get('on_publish_debug');
var on_deliver_debug = config.get('on_deliver_debug'); var on_deliver_debug = config.get('on_deliver_debug');
var on_unsubscribe_debug = config.get('on_unsubscribe_debug'); var on_unsubscribe_debug = config.get('on_unsubscribe_debug');
var on_offline_debug = config.get('on_offline_debug');
var restify = require('restify'); var restify = require('restify');
var auth_on_register = require('./auth_on_register')({ debug: auth_on_register_debug }); var auth_on_register = require('./auth_on_register')({ debug: auth_on_register_debug });
...@@ -15,6 +16,7 @@ var auth_on_subscribe = require('./auth_on_subscribe')({ debug: auth_on_subscrib ...@@ -15,6 +16,7 @@ var auth_on_subscribe = require('./auth_on_subscribe')({ debug: auth_on_subscrib
var on_publish = require('./on_publish')({ debug: on_publish_debug }); var on_publish = require('./on_publish')({ debug: on_publish_debug });
var on_deliver = require('./on_deliver')({ debug: on_deliver_debug }); var on_deliver = require('./on_deliver')({ debug: on_deliver_debug });
var on_unsubscribe = require('./on_unsubscribe')({ debug: on_unsubscribe_debug }); var on_unsubscribe = require('./on_unsubscribe')({ debug: on_unsubscribe_debug });
var on_offline = require('./on_offline')({ debug: on_offline_debug });
const server = restify.createServer({ const server = restify.createServer({
name: 'authhook', name: 'authhook',
...@@ -37,13 +39,15 @@ server.get('/about', function (req, res, next) { ...@@ -37,13 +39,15 @@ server.get('/about', function (req, res, next) {
server.post('/authreg', auth_on_register); server.post('/authreg', auth_on_register);
server.post('/authpub', auth_on_publish); server.post('/authpub', auth_on_publish);
server.post('/authsub', auth_on_subscribe); server.post('/authsub', auth_on_subscribe);
server.post('/onsub', (req,res,next) => { server.post('/onsub', (req, res, next) => {
console.log(req.body) console.log(req.body)
res.send('') res.send('')
}) })
server.post('/onunsub', on_unsubscribe) server.post('/onunsub', on_unsubscribe)
server.post('/ondeliver', on_deliver) server.post('/ondeliver', on_deliver)
server.post('/onpub', on_publish) server.post('/onpub', on_publish)
server.post('/onoff', on_offline)
server.post('/ongone', on_offline)
server.listen(port, function () { server.listen(port, function () {
console.log('%s listening at %s', server.name, server.url); console.log('%s listening at %s', server.name, server.url);
......
module.exports = function(options = {}) {
return function (req, res, next) {
doRedis()
}
function doRedis() {
}
}
\ No newline at end of file
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