mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-02-06 06:54:58 +00:00
Create ipctest.js
This commit is contained in:
parent
9080a177f1
commit
d05d4deb03
32
examples/ipctest.js
Normal file
32
examples/ipctest.js
Normal file
|
@ -0,0 +1,32 @@
|
|||
// a mafia style PIPE IPC based file I/O test
|
||||
|
||||
var FILE = require("lib/file");
|
||||
var filename = "data\\dead_targets.txt";
|
||||
|
||||
function recordDead(name) {
|
||||
FILE.rotateFile(filename, name + "\r\n", 1000, "utf-8");
|
||||
}
|
||||
|
||||
function checkIsDead(name) {
|
||||
var text = FILE.readFile(filename, "utf-8");
|
||||
var deadNames = splitLn(text);
|
||||
return deadNames.indexOf(name) > -1;
|
||||
}
|
||||
|
||||
function main(args) {
|
||||
while (true) {
|
||||
recordDead("kim@example.org");
|
||||
//recordDead("lee@example.org");
|
||||
recordDead("park@example.org");
|
||||
//recordDead("choi@example.org");
|
||||
recordDead("hong@example.org");
|
||||
|
||||
console.log(checkIsDead("kim@example.org") ? "DEAD" : "ALIVE");
|
||||
console.log(checkIsDead("lee@example.org") ? "DEAD" : "ALIVE");
|
||||
console.log(checkIsDead("park@example.org") ? "DEAD" : "ALIVE");
|
||||
console.log(checkIsDead("choi@example.org") ? "DEAD" : "ALIVE");
|
||||
console.log(checkIsDead("hong@example.org") ? "DEAD" : "ALIVE");
|
||||
}
|
||||
}
|
||||
|
||||
exports.main = main;
|
Loading…
Reference in New Issue
Block a user