mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
Replaced contract I/O pipes with domain sockets. (#140)
This commit is contained in:
committed by
GitHub
parent
37cc27c5ce
commit
7a4515865d
@@ -9,16 +9,16 @@ const hpc = new HotPocketContract();
|
||||
if (!hpc.readonly)
|
||||
fs.appendFileSync("exects.txt", "ts:" + hpc.timestamp + "\n");
|
||||
|
||||
Object.keys(hpc.users).forEach(async (key) => {
|
||||
|
||||
const user = hpc.users[key];
|
||||
const inputBuf = await user.readInput();
|
||||
if (inputBuf) {
|
||||
const userInput = inputBuf.toString("utf8");
|
||||
if (userInput == "ts")
|
||||
user.sendOutput(fs.readFileSync("exects.txt"));
|
||||
else
|
||||
user.sendOutput("Echoing: " + userInput);
|
||||
hpc.events.on("user_message", (pubKey, message) => {
|
||||
const userInput = message.toString("utf8");
|
||||
const user = hpc.users[pubKey];
|
||||
if (userInput == "ts") {
|
||||
user.sendOutput(fs.readFileSync("exects.txt"));
|
||||
user.closeChannel();
|
||||
}
|
||||
else {
|
||||
user.sendOutput("Echoing: " + userInput);
|
||||
user.closeChannel();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -30,6 +30,19 @@ if (npl) {
|
||||
npl.closeNplChannel();
|
||||
}
|
||||
|
||||
// HP <--> SC
|
||||
const hp = hpc.control;
|
||||
hp.closeControlChannel();
|
||||
|
||||
// let i = 0;
|
||||
// hp.events.on('message', (msg) => {
|
||||
// console.log('control msg - ' + msg);
|
||||
// hp.sendOutput(msg);
|
||||
// i++;
|
||||
// if (i == 2)
|
||||
// hp.closeControlChannel();
|
||||
// })
|
||||
|
||||
// Npl message sending and receiving template.
|
||||
// if (npl) {
|
||||
// let i = 0;
|
||||
|
||||
Reference in New Issue
Block a user