Update testloader.js #96

This commit is contained in:
Namhyeon Go 2024-01-04 12:05:47 +09:00
parent 5ffdea15de
commit dddfa3cc47
2 changed files with 29 additions and 4 deletions

View File

@ -1,7 +1,7 @@
{
"description": "WelsonJS test profile for Miscellaneous",
"date": "2023-11-07",
"revision": "20231107r1",
"description": "WelsonJS test profile (test-misc.json)",
"date": "2024-01-04",
"revision": "HEAD",
"authors": [
"Namhyeon Go <gnh1201@gmail.com>"
],
@ -52,6 +52,11 @@
{
"id": "sharedmemory",
"description": "Write and read a text on the (named) shared memory",
"tags": ["Windows System", "IPC(Inter-Process Communication)"]
},
{
"id": "sharedmemory_listener",
"description": "Read a text form the (named) shared memory, Repeatly",
"tags": ["Windows System", "IPC(Inter-Process Communication)"]
}
]

View File

@ -858,6 +858,26 @@ var test_implements = {
console.log("Closing the shared memory...");
console.log("Done");
},
"sharedmemory_listener": function() {
var Toolkit = require("lib/toolkit");
var mem;
var memName = Toolkit.prompt("Input the shared memory name");
if (!memName) {
console.log("Aborted.");
} else {
mem = new Toolkit.NamedSharedMemory(memName);
console.log("Listening the shared memory:", memName);
while (true) {
var message = mem.readText(memName);
if (!!message) {
console.log(memName + ": " + message);
}
sleep(1);
}
}
}
};