Commit 69c2caad by Chavee Issariyapat

merge from master

parents 7ac5ed06 a6ab5fd5
.DS_Store
node_modules/
config/*.json
......@@ -6,11 +6,6 @@ var LRU = require("lru-cache"),
maxAge: 1000 * 60 * 5
});
// for testing
// function authCheck(client_id, username, topic, callback) {
// callback(true);
// }
module.exports = function (options = {}) {
return function (req, res, next) {
......@@ -43,8 +38,7 @@ module.exports = function (options = {}) {
var output = {};
GGID.getGroupID(req.body.username, req.body.client_id, function(group) {
var _ftopic = require('./utils/getTopic').rewriteTopic(topic, 'pub', group, req.body.client_id, output); // get topic where concat with groupID
var _ftopic = require('./utils/router').rewriteTopic(topic, 'pub', group, req.body.client_id, output); // get topic where concat with groupID
response = {
'result': 'ok',
'modifiers': {
......@@ -72,4 +66,4 @@ module.exports = function (options = {}) {
next();
}
}
}
\ No newline at end of file
}
......@@ -38,7 +38,7 @@ module.exports = function (options = {}) {
GGID.getGroupID(req.body.username, req.body.client_id, function(group) {
console.log(group);
var _ftopic = require('./utils/getTopic').rewriteTopic(topic, 'sub', group, req.body.client_id) // get topic where concat with groupID
var _ftopic = require('./utils/router').rewriteTopic(topic, 'sub', group, req.body.client_id) // get topic where concat with groupID
var _topic = [{ // setTopic for response
'topic': _ftopic,
'qos': 0
......
{
"authserv_host" : "AUTH_SERVICE_HOST",
"authserv_port" : "AUTH_SERVICE_PORT",
"authserv_host" : "AUTH_SERVICE_HOST",
"authserv_port" : "AUTH_SERVICE_PORT",
"device_registry_host" : "DEVICE_REGISTRY_HOST",
"device_registry_port" : "DEVICE_REGISTRY_PORT"
"device_registry_host" : "DEVICE_REGISTRY_HOST",
"device_registry_port" : "DEVICE_REGISTRY_PORT",
"auth_on_register_debug" : "AUTH_ON_REGISTER_DEBUG",
"auth_on_publish_debug" : "AUTH_ON_PUBLISH_DEBUG",
"auth_on_subscribe_debug" : "AUTH_ON_SUBSCRIBE_DEBUG",
"on_publish_debug" : "ON_PUBLISH_DEBUG",
"on_deliver_debug" : "ON_DELIVER_DEBUG",
"on_unsubscribe_debug" : "ON_UNSUBSCRIBE_DEBUG"
}
process.env["NODE_ENV"] = "development";
process.env["NODE_CONFIG_DIR"] = __dirname + "/config/";
var auth_on_register_debug = process.env["AUTH_ON_REGISTER_DEBUG"] || false;
var auth_on_publish_debug = process.env["AUTH_ON_PUBLISH_DEBUG"] || true;
var auth_on_subscribe_debug = process.env["AUTH_ON_SUBSCRIBE_DEBUG"] || true;
var on_publish_debug = process.env["ON_PUBLISH_DEBUG"] || true;
var on_deliver_debug = process.env["ON_DELIVER_DEBUG"] || true;
var on_unsubscribe_debug = process.env["ON_UNSUBSCRIBE_DEBUG"] || true;
var config = require('config');
var auth_on_register_debug = config.get('auth_on_register_debug');
var auth_on_publish_debug = config.get('auth_on_publish_debug');
var auth_on_subscribe_debug = config.get('auth_on_subscribe_debug');
var on_publish_debug = config.get('on_publish_debug');
var on_deliver_debug = config.get('on_deliver_debug');
var on_unsubscribe_debug = config.get('on_unsubscribe_debug');
var restify = require('restify');
var auth_on_register = require('./auth_on_register')({ debug: auth_on_register_debug });
......
......@@ -21,4 +21,4 @@ module.exports = function(options = {}) {
var topic = topics.split('/!')[1]
return topics.split('/!')[0] + topic.substring(topic.indexOf('/'), topic.length)
}
}
\ No newline at end of file
}
......@@ -18,10 +18,10 @@ module.exports = function(options = {}) {
}
else {
var GGID = require('./utils/getGroupID');
GGID.getGroupID(token, client_id, function(group) {
if (group) {
var _ftopic = require('./utils/getTopic').rewriteTopic(topic, 'unsub', group, client_id)
var _ftopic = require('./utils/router').rewriteTopic(topic, 'unsub', group, client_id)
response = {
"result": "ok",
"topics": [_ftopic]
......@@ -39,4 +39,4 @@ module.exports = function(options = {}) {
});
}
}
}
\ No newline at end of file
}
var assert = require('assert')
var getTopic = require('../utils/getTopic').getTopic
var getTopic = require('../utils/router').rewriteTopic
describe('GetTopic', () => {
describe('realtime msg', () => {
......@@ -49,4 +49,4 @@ describe('GetTopic', () => {
})
})
})
})
\ No newline at end of file
})
......@@ -2,19 +2,16 @@ var modify = require('./modify');
function rewriteTopic(topic, op, groupid, clientid, output) {
var chunk = topic.split('/');
console.log(groupid);
switch (chunk[0]) {
case '@msg' :
return modify.insertWordIntoTopic(topic, '!'+groupid, 1);
case '@shadow' :
if (chunk[1] == 'write' || chunk[1] == 'read') {
if (chunk[1] == 'set' || chunk[1] == 'get') {
output.verb = chunk[1];
return modify.insertWordIntoTopic(topic, ''+clientid, 2);
}
else if (chunk[1] == 'set' || chunk[1] == 'get') {
else if (chunk[1] == 'write' || chunk[1] == 'read') {
output.verb = chunk[1];
return modify.insertWordIntoTopic(topic, groupid, 2);
}
......@@ -44,4 +41,4 @@ console.log(groupid);
}
}
module.exports.rewriteTopic = rewriteTopic
\ No newline at end of file
module.exports.rewriteTopic = rewriteTopic
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