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", "description": "WelsonJS test profile (test-misc.json)",
"date": "2023-11-07", "date": "2024-01-04",
"revision": "20231107r1", "revision": "HEAD",
"authors": [ "authors": [
"Namhyeon Go <gnh1201@gmail.com>" "Namhyeon Go <gnh1201@gmail.com>"
], ],
@ -53,6 +53,11 @@
"id": "sharedmemory", "id": "sharedmemory",
"description": "Write and read a text on the (named) shared memory", "description": "Write and read a text on the (named) shared memory",
"tags": ["Windows System", "IPC(Inter-Process Communication)"] "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("Closing the shared memory...");
console.log("Done"); 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);
}
}
} }
}; };