I hate race conditions
This commit is contained in:
@@ -46,13 +46,14 @@ export default class QMPClient extends EventEmitter {
|
||||
}
|
||||
|
||||
private async onData(data : Buffer) {
|
||||
let msgraw = data.toString();
|
||||
let msgraw = data.toString().split("\n");
|
||||
for(var message in msgraw) {
|
||||
let msg;
|
||||
|
||||
try {
|
||||
msg = JSON.parse(msgraw);
|
||||
msg = JSON.parse(msgraw[message]);
|
||||
} catch {
|
||||
this.emit("qmpreturn", '');
|
||||
this.emit("qmpreturn", "");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -82,14 +83,15 @@ export default class QMPClient extends EventEmitter {
|
||||
break;
|
||||
};
|
||||
default: {
|
||||
this.emit("qmpreturn", '');
|
||||
this.emit("qmpreturn", "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}else
|
||||
// for now just return an empty string.
|
||||
// This is a giant hack but avoids a deadlock
|
||||
this.emit("qmpreturn", '');
|
||||
this.emit("qmpreturn", "");
|
||||
}
|
||||
}
|
||||
|
||||
private onClose() {
|
||||
|
||||
Reference in New Issue
Block a user