Commit 9eaf05bb by amir

fix overrite the json nodes

parent 5ee7a320
Showing with 7 additions and 4 deletions
......@@ -9,6 +9,8 @@ const request = require('request');
var myArgs = require('optimist').argv,
help = 'node app.js -p port -f file-path [-d delay-between-samples --postUrl http url to post instead of websocket]';
//const twoDaysAgoMs = 1000 * 3600 * 47;
/**
* some validation
*/
......@@ -92,11 +94,12 @@ var normalyzeEvent = function(eventObj){
var sendJson = function(){
wss.clients.forEach(function each(client) {
var eventObj = jsonFile[index];
normalyzeEvent(eventObj);
console.log("sending: " + JSON.stringify(eventObj));
var newEventObj = JSON.parse(JSON.stringify(eventObj))
normalyzeEvent(newEventObj);
console.log("sending: " + JSON.stringify(newEventObj));
if (myArgs.postUrl == null){
if (client.readyState === WebSocket.OPEN) {
client.send(JSON.stringify(eventObj));
client.send(JSON.stringify(newEventObj));
}
} else {
request.post({
......@@ -104,7 +107,7 @@ var sendJson = function(){
headers: {
"Content-Type": "application/json"
},
body: eventObj,
body: newEventObj,
json:true
}, function(error, response, body){
console.log(error);
......
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 sign in to comment