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,34 +26,32 @@ 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(':');
if (stopic && ptext) {
switch (a[0]) {
case 'wf' :
case 'writefeed' :
switch (a[1]) {
case 'wf' :
case 'writefeed' :
var data = [{
"name": a[2],
"timestamp": Date.now(),
"topic": data.topic,
"payload":ptext,
var msg = [{
"topic": stopic,
"payload":ptext,
"ts": Date.now(),
"cid": data.client_id,
}];
"value": p[1], // temp
"tags":{"attr":p[0]} // temp
}];
client.act('cmd:wf', {
message: JSON.stringify(msg)
}, (err, res) => {
if (err) {
throw err;
}
});
client.act('cmd:writefeed,feedid:serialno', {
message: JSON.stringify(data)
}, (err, res) => {
if (err) {
throw err;
}
});
break;
break;
}
}
}
......
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