Update pipe-ipc.js

This commit is contained in:
Namhyeon Go 2022-09-27 18:35:25 +09:00 committed by GitHub
parent 3294e23e59
commit 1ed17cc5c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -44,13 +44,17 @@ function PipeIPC() {
this.reader = null; this.reader = null;
}; };
this._write = function(message) {
this.writer.Write(message);
};
this.write = function(message) { this.write = function(message) {
var isWritten = false; var isWritten = false;
while (!isWritten) { while (!isWritten) {
try { try {
this.createWriter(); this.createWriter();
this.writer.Write(message); this._write(message);
sleep(1); sleep(1);
this.writer.Close(); this.writer.Close();
isWritten = true; isWritten = true;
@ -60,13 +64,17 @@ function PipeIPC() {
} }
}; };
this._read = function() {
return this.reader.ReadAll();
};
this.read = function() { this.read = function() {
var isRead = false; var isRead = false;
var text = ""; var text = "";
while (!isRead) { while (!isRead) {
try { try {
text = this.reader.ReadAll(); text = this._read();
isRead = true; isRead = true;
} catch (e) { } catch (e) {
this.closeReader(); this.closeReader();