Commit b8c89812 by Chavee Issariyapat

change msg format

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