Commit e8b048cd by Chavee Issariyapat

fix seneca

parent 877a1dc1
{
"rabbitmq_host" : "npn1.kube.nexpie.com",
"rabbitmq_port" : "31672",
"rabbitmq_port" : "32672",
"rabbitmq_username" : "b1ffb9e39865f3cb70cc2ef14920e023",
"rabbitmq_password" : "c3efbc0c4bdb1747a31cebac20d9b9b8"
}
process.env["NODE_ENV"] = "development";
process.env["NODE_CONFIG_DIR"] = __dirname + "/config/";
// process.env["NODE_ENV"] = "development";
// process.env["NODE_CONFIG_DIR"] = __dirname + "/config/";
var restify = require('restify');
var on_publish = require('./on_publish')({debug:true});
......
......@@ -6,7 +6,7 @@ var LRU = require("lru-cache") ,
maxAge: 1000 * 60 * 5
});
var client = require('seneca')()
var client_wf = require('seneca')()
.use('seneca-amqp-transport')
.client({
type: 'amqp',
......@@ -15,6 +15,16 @@ var client = require('seneca')()
});
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) {
......@@ -31,19 +41,18 @@ module.exports = function(options={}) {
var ptext = Buffer.from(data.payload, 'base64').toString();
if (stopic && ptext) {
let msg;
switch (a[0]) {
case 'wf' :
case 'writefeed' :
msg = [{
let wfmsg = [{
"topic": stopic,
"payload":ptext,
"ts": Date.now(),
"cid": data.client_id,
}];
client.act('cmd:wf', {
message: JSON.stringify(msg)
client_wf.act('cmd:wf', {
message: JSON.stringify(wfmsg)
}, (err, res) => {
if (err) {
throw err;
......@@ -52,14 +61,14 @@ module.exports = function(options={}) {
break;
case 'push' :
msg = [{
let pushmsg = [{
"topic": stopic,
"payload":ptext,
"ts": Date.now(),
"cid": data.client_id,
}];
client.act('cmd:push', {
message: JSON.stringify(msg)
client_push.act('cmd:push', {
message: JSON.stringify(pushmsg)
}, (err, res) => {
if (err) {
throw err;
......
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