Commit 482eee0e by Chavee Issariyapat

fix seneca client error

parent 9595fd04
......@@ -7,36 +7,11 @@ var LRU = require("lru-cache") ,
});
var senecaAMQP = require('seneca')().use('seneca-amqp-transport');
var client_wf = senecaAMQP.client({
var client = senecaAMQP.client({
type: 'amqp',
pin: 'cmd:wf',
pin: ['cmd:wf','ms:kbpush,cmd:push'],
url: 'amqp://'+config.get('rabbitmq_username')+':'+config.get('rabbitmq_password')+'@'+config.get('rabbitmq_host')+':'+config.get('rabbitmq_port')
});
var client_push = senecaAMQP.client({
type: 'amqp',
pin: 'cmd:push',
url: 'amqp://'+config.get('rabbitmq_username')+':'+config.get('rabbitmq_password')+'@'+config.get('rabbitmq_host')+':'+config.get('rabbitmq_port')
});
// var client_wf = require('seneca')()
// .use('seneca-amqp-transport')
// .client({
// type: 'amqp',
// pin: 'cmd:wf',
// url: 'amqp://'+config.get('rabbitmq_username')+':'+config.get('rabbitmq_password')+'@'+config.get('rabbitmq_host')+':'+config.get('rabbitmq_port')
// });
// var client_push = require('seneca')()
// .use('seneca-amqp-transport')
// .client({
// type: 'amqp',
// pin: 'cmd:push',
// url: 'amqp://'+config.get('rabbitmq_username')+':'+config.get('rabbitmq_password')+'@'+config.get('rabbitmq_host')+':'+config.get('rabbitmq_port')
// });
module.exports = function(options={}) {
return function(req, res, next) {
......@@ -64,7 +39,7 @@ module.exports = function(options={}) {
"cid": data.client_id,
}];
client_wf.act('cmd:wf', {
client.act('cmd:wf', {
message: JSON.stringify(wfmsg)
}, (err, res) => {
if (err) {
......@@ -80,7 +55,7 @@ module.exports = function(options={}) {
"ts": Date.now(),
"cid": data.client_id,
}];
client_push.act('cmd:push', {
client.act('ms:kbpush,cmd:push', {
message: JSON.stringify(pushmsg)
}, (err, res) => {
if (err) {
......@@ -108,3 +83,42 @@ module.exports = function(options={}) {
}
}
}
// setInterval( function() {
// console.log('Fire...');
// let wfmsg = [{
// "topic": 'wf/30AEA47F2830',
// "payload":"F2:20",
// "ts": Date.now(),
// "cid": '30AEA47F2830',
// }];
// client.act('cmd:wf', {
// message: JSON.stringify(wfmsg)
// }, (err, res) => {
// if (err) {
// throw err;
// }
// });
// let pushmsg = [{
// "topic": 'title',
// "payload":"hello world",
// "ts": Date.now(),
// "cid": '30AEA47F2830',
// }];
// client.act('ms:kbpush,cmd:push', {
// message: JSON.stringify(pushmsg)
// }, (err, res) => {
// if (err) {
// throw err;
// }
// });
// },1000);
......@@ -13,6 +13,7 @@
"lru-cache": "^4.1.3",
"restify": "^7.1.1",
"seneca": "^3.6.0",
"seneca-amqp-transport": "^2.2.0"
"seneca-amqp-transport": "^2.2.0",
"seneca-fire-and-forget": "^1.0.0"
}
}
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