Commit 69c2caad by Chavee Issariyapat

merge from master

parents 7ac5ed06 a6ab5fd5
.DS_Store .DS_Store
node_modules/ node_modules/
config/*.json
...@@ -6,11 +6,6 @@ var LRU = require("lru-cache"), ...@@ -6,11 +6,6 @@ var LRU = require("lru-cache"),
maxAge: 1000 * 60 * 5 maxAge: 1000 * 60 * 5
}); });
// for testing
// function authCheck(client_id, username, topic, callback) {
// callback(true);
// }
module.exports = function (options = {}) { module.exports = function (options = {}) {
return function (req, res, next) { return function (req, res, next) {
...@@ -43,8 +38,7 @@ module.exports = function (options = {}) { ...@@ -43,8 +38,7 @@ module.exports = function (options = {}) {
var output = {}; var output = {};
GGID.getGroupID(req.body.username, req.body.client_id, function(group) { GGID.getGroupID(req.body.username, req.body.client_id, function(group) {
var _ftopic = require('./utils/router').rewriteTopic(topic, 'pub', group, req.body.client_id, output); // get topic where concat with groupID
var _ftopic = require('./utils/getTopic').rewriteTopic(topic, 'pub', group, req.body.client_id, output); // get topic where concat with groupID
response = { response = {
'result': 'ok', 'result': 'ok',
'modifiers': { 'modifiers': {
......
...@@ -38,7 +38,7 @@ module.exports = function (options = {}) { ...@@ -38,7 +38,7 @@ module.exports = function (options = {}) {
GGID.getGroupID(req.body.username, req.body.client_id, function(group) { GGID.getGroupID(req.body.username, req.body.client_id, function(group) {
console.log(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 var _topic = [{ // setTopic for response
'topic': _ftopic, 'topic': _ftopic,
'qos': 0 'qos': 0
......
...@@ -3,5 +3,12 @@ ...@@ -3,5 +3,12 @@
"authserv_port" : "AUTH_SERVICE_PORT", "authserv_port" : "AUTH_SERVICE_PORT",
"device_registry_host" : "DEVICE_REGISTRY_HOST", "device_registry_host" : "DEVICE_REGISTRY_HOST",
"device_registry_port" : "DEVICE_REGISTRY_PORT" "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/"; process.env["NODE_CONFIG_DIR"] = __dirname + "/config/";
var config = require('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_register_debug = config.get('auth_on_register_debug');
var auth_on_subscribe_debug = process.env["AUTH_ON_SUBSCRIBE_DEBUG"] || true; var auth_on_publish_debug = config.get('auth_on_publish_debug');
var on_publish_debug = process.env["ON_PUBLISH_DEBUG"] || true; var auth_on_subscribe_debug = config.get('auth_on_subscribe_debug');
var on_deliver_debug = process.env["ON_DELIVER_DEBUG"] || true; var on_publish_debug = config.get('on_publish_debug');
var on_unsubscribe_debug = process.env["ON_UNSUBSCRIBE_DEBUG"] || true; var on_deliver_debug = config.get('on_deliver_debug');
var on_unsubscribe_debug = config.get('on_unsubscribe_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 });
......
...@@ -21,7 +21,7 @@ module.exports = function(options = {}) { ...@@ -21,7 +21,7 @@ module.exports = function(options = {}) {
GGID.getGroupID(token, client_id, function(group) { GGID.getGroupID(token, client_id, function(group) {
if (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 = { response = {
"result": "ok", "result": "ok",
"topics": [_ftopic] "topics": [_ftopic]
......
var assert = require('assert') var assert = require('assert')
var getTopic = require('../utils/getTopic').getTopic var getTopic = require('../utils/router').rewriteTopic
describe('GetTopic', () => { describe('GetTopic', () => {
describe('realtime msg', () => { describe('realtime msg', () => {
......
...@@ -2,19 +2,16 @@ var modify = require('./modify'); ...@@ -2,19 +2,16 @@ var modify = require('./modify');
function rewriteTopic(topic, op, groupid, clientid, output) { function rewriteTopic(topic, op, groupid, clientid, output) {
var chunk = topic.split('/'); var chunk = topic.split('/');
console.log(groupid);
switch (chunk[0]) { switch (chunk[0]) {
case '@msg' : case '@msg' :
return modify.insertWordIntoTopic(topic, '!'+groupid, 1); return modify.insertWordIntoTopic(topic, '!'+groupid, 1);
case '@shadow' : case '@shadow' :
if (chunk[1] == 'write' || chunk[1] == 'read') { if (chunk[1] == 'set' || chunk[1] == 'get') {
output.verb = chunk[1]; output.verb = chunk[1];
return modify.insertWordIntoTopic(topic, ''+clientid, 2); 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]; output.verb = chunk[1];
return modify.insertWordIntoTopic(topic, groupid, 2); return modify.insertWordIntoTopic(topic, groupid, 2);
} }
......
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