Commit 1d36c327 by zCaesar

add offline status

parent 4c2fd35d
...@@ -116,9 +116,12 @@ module.exports = function (options = {}) { ...@@ -116,9 +116,12 @@ module.exports = function (options = {}) {
}); });
} }
else { else {
require('./redis/on_register').on_register_redis(req.body.client_id).then(status => {
console.log('redis:status: ' + status)
res.send({ res.send({
"result": authstatus ? "ok" : "no" "result": status ? "ok" : "no"
}); });
})
} }
next(); next();
} }
......
...@@ -7,7 +7,7 @@ var auth_on_subscribe_debug = config.get('auth_on_subscribe_debug'); ...@@ -7,7 +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 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 });
...@@ -16,8 +16,7 @@ var auth_on_subscribe = require('./auth_on_subscribe')({ debug: auth_on_subscrib ...@@ -16,8 +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 }); var on_offline = require('./on_offline')({ debug: on_offline_debug });
var on_offline = require('./redis/on_offline').on_offline_redis
const server = restify.createServer({ const server = restify.createServer({
name: 'authhook', name: 'authhook',
...@@ -47,8 +46,8 @@ server.post('/onsub', (req, res, next) => { ...@@ -47,8 +46,8 @@ server.post('/onsub', (req, res, next) => {
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(req.body.client_id)) server.post('/onoff', on_offline)
server.post('/ongone', on_offline(req.body.client_id)) 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 = {}) { module.exports = function(options = {}) {
debug = options.debug || false;
return function (req, res, next) { return function (req, res, next) {
doRedis(req.body) doRedis(req.body.client_id)
} }
function doRedis(body) { function doRedis(client_id) {
console.log(body) require('./redis/on_offline').on_offline_redis(client_id).then(status => {
console.log('redis:status: ' + status)
})
} }
} }
\ 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