mpc: handle ACK responses
authorMike Frysinger <vapier@gentoo.org>
Sun, 1 Sep 2013 10:46:31 +0000 (06:46 -0400)
committerMike Frysinger <vapier@gentoo.org>
Sun, 1 Sep 2013 10:46:31 +0000 (06:46 -0400)
js/mpc.js

index dfcd5fd304278d8d520e637ad98f560dd06c25a1..ae013332e618a7700ae0e5a75f4d913c3f94f671 100644 (file)
--- a/js/mpc.js
+++ b/js/mpc.js
@@ -34,6 +34,8 @@ Mpc.prototype.send = function(msg) {
 Mpc.prototype.recv_msg = function(lines) {
        curr = this._queue.shift();
        this.log(0x2, 'recv: [' + curr + ']:', lines.join('\n'));
+       if (lines[0].substr(0, 4) == 'ACK ')
+               this.err(curr, lines.join('\n'));
        curr = curr.split(' ');
 
        switch (curr[0]) {
@@ -79,7 +81,8 @@ Mpc.prototype.recv = function(msg) {
        var lines = this._recv_buffer = this._recv_buffer.concat(msg.split('\n'));
        var i = 0;
        while (i < lines.length) {
-               if (lines[i] == 'OK' || lines[i].substr(0, 3) == 'OK ') {
+               if (lines[i] == 'OK' || lines[i].substr(0, 3) == 'OK ' ||
+                   lines[i].substr(0, 4) == 'ACK ') {
                        this.recv_msg(lines.splice(0, i + 1));
                        i = 0;
                } else