Commit b8c89812 by Chavee Issariyapat

change msg format

parent de63d9cf
......@@ -10,7 +10,7 @@ var client = require('seneca')()
.use('seneca-amqp-transport')
.client({
type: 'amqp',
pin: 'cmd:writefeed,feedid:serialno',
pin: 'cmd:wf',
url: 'amqp://'+config.get('rabbitmq_username')+':'+config.get('rabbitmq_password')+'@'+config.get('rabbitmq_host')+':'+config.get('rabbitmq_port')
});
......@@ -26,27 +26,24 @@ module.exports = function(options={}) {
var data = req.body;
if (data.topic.substring(0,5) == '$exec') {
var stopic = data.topic.substr(6);
var a = data.topic.split('/');
var ptext = Buffer.from(data.payload, 'base64').toString();
// temp
var p = ptext.split(':');
switch (a[1]) {
if (stopic && ptext) {
switch (a[0]) {
case 'wf' :
case 'writefeed' :
var data = [{
"name": a[2],
"timestamp": Date.now(),
"topic": data.topic,
"payload":ptext,
"value": p[1], // temp
"tags":{"attr":p[0]} // temp
var msg = [{
"topic": stopic,
"payload":ptext,
"ts": Date.now(),
"cid": data.client_id,
}];
client.act('cmd:writefeed,feedid:serialno', {
message: JSON.stringify(data)
client.act('cmd:wf', {
message: JSON.stringify(msg)
}, (err, res) => {
if (err) {
throw err;
......@@ -56,6 +53,7 @@ module.exports = function(options={}) {
break;
}
}
}
var topic = req.body.topic;
var cachekey = 'pub:'+req.body.client_id +':'+ req.body.username+':'+topic;
......
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