json
This commit is contained in:
parent
8c5826972b
commit
41deb6a749
1 changed files with 6 additions and 5 deletions
11
index.js
11
index.js
|
@ -16,10 +16,11 @@ function initConnection(ws, server, port) {
|
||||||
let commandQueue = [];
|
let commandQueue = [];
|
||||||
let command = null;
|
let command = null;
|
||||||
|
|
||||||
function waitForCommand(command) {
|
function waitForCommand(cmd) {
|
||||||
command.on("done", data => {
|
command = cmd;
|
||||||
|
cmd.on("done", data => {
|
||||||
log("ws <--", data);
|
log("ws <--", data);
|
||||||
ws.send(data);
|
ws.send(JSON.stringify(data));
|
||||||
command = null;
|
command = null;
|
||||||
processQueue();
|
processQueue();
|
||||||
});
|
});
|
||||||
|
@ -27,8 +28,8 @@ function initConnection(ws, server, port) {
|
||||||
|
|
||||||
function processQueue() {
|
function processQueue() {
|
||||||
if (command || !commandQueue.length) { return; }
|
if (command || !commandQueue.length) { return; }
|
||||||
command = commands.create(mpd, commandQueue.shift());
|
let cmd = commands.create(mpd, commandQueue.shift());
|
||||||
waitForCommand(command);
|
waitForCommand(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
ws.on("message", message => {
|
ws.on("message", message => {
|
||||||
|
|
Loading…
Reference in a new issue