Commit 8a56c7cf by Chavee Issariyapat

update

parent 5c1f7201
...@@ -24,36 +24,22 @@ module.exports = function(options={}) { ...@@ -24,36 +24,22 @@ module.exports = function(options={}) {
console.log(req.body); console.log(req.body);
} }
var data = req.body; var data = req.body;
console.log(123);
console.log(data.topic.substring(0,5));
//1----
console.log('amqp://'+config.get('rabbitmq_username')+':'+config.get('rabbitmq_password')+'@'+config.get('rabbitmq_host')+':'+config.get('rabbitmq_port'));
if (data.topic.substring(0,5) == '$exec') { if (data.topic.substring(0,5) == '$exec') {
console.log(555);
var stopic = data.topic.substr(6); var stopic = data.topic.substr(6);
var a = stopic.split('/'); var a = stopic.split('/');
var ptext = Buffer.from(data.payload, 'base64').toString(); var ptext = Buffer.from(data.payload, 'base64').toString();
console.log(stopic);
console.log(ptext);
if (stopic && ptext) { if (stopic && ptext) {
console.log(a);
switch (a[0]) { switch (a[0]) {
case 'wf' : case 'wf' :
case 'writefeed' : case 'writefeed' :
var wfmsg = [{ var wfmsg = {
"topic": stopic, "topic": stopic,
"payload":ptext, "payload":ptext,
"ts": Date.now(), "ts": Date.now(),
"cid": data.client_id "cid": data.client_id
}]; };
console.log(1111);
console.log(wfmsg);
client.act('cmd:wf', { client.act('cmd:wf', {
message: JSON.stringify(wfmsg) message: JSON.stringify(wfmsg)
}, (err, res) => { }, (err, res) => {
...@@ -65,12 +51,12 @@ console.log(wfmsg); ...@@ -65,12 +51,12 @@ console.log(wfmsg);
break; break;
case 'push' : case 'push' :
var pushmsg = [{ var pushmsg = {
"topic": stopic, "topic": stopic,
"payload":ptext, "payload":ptext,
"ts": Date.now(), "ts": Date.now(),
"cid": data.client_id, "cid": data.client_id,
}]; };
client.act('ms:kbpush,cmd:push', { client.act('ms:kbpush,cmd:push', {
message: JSON.stringify(pushmsg) message: JSON.stringify(pushmsg)
}, (err, res) => { }, (err, res) => {
......
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