Implemented sending contract output back to the user.

This commit is contained in:
Ravin Perera
2019-10-16 17:26:33 +05:30
parent 8b003aeaa2
commit 8a22748c8d
7 changed files with 121 additions and 44 deletions

View File

@@ -10,13 +10,15 @@ console.log("Input received from hp: " + input);
let hpargs = JSON.parse(input);
Object.keys(hpargs.usrfd).forEach(function(key,index) {
Object.keys(hpargs.usrfd).forEach(function (key, index) {
let userfds = hpargs.usrfd[key];
let userinput = Buffer.from(pipe.getfdbytes(userfds[0])).toString();
console.log("Input received from user " + key + ":");
console.log(userinput);
let userinput = Buffer.from(pipe.getfdbytes(userfds[0])).toString().trim();
fs.writeSync(userfds[1], "Echoing: " + userinput);
if (userinput.length > 0) {
console.log("Input received from user " + key + ":");
console.log(userinput);
fs.writeSync(userfds[1], "Echoing: " + userinput);
}
});
console.log("===Sample contract ended===");