]> git.wh0rd.org Git - chrome-ext/music-player-client.git/commitdiff
handle connection errors v3.2
authorMike Frysinger <vapier@gentoo.org>
Sat, 28 Sep 2013 05:07:03 +0000 (01:07 -0400)
committerMike Frysinger <vapier@gentoo.org>
Sat, 28 Sep 2013 05:24:25 +0000 (01:24 -0400)
If we fail to connect, don't initialize mpc objects and such.
Update the UI so the user can see that things are hosed.

main.js
manifest.json

diff --git a/main.js b/main.js
index 16875983968fd05b34c142910747a369b2bb5517..3ff3ca46906251888f02af57737083d149c446e0 100644 (file)
--- a/main.js
+++ b/main.js
@@ -103,7 +103,12 @@ function mpc_connect(host, port) {
 
        update_ui('init');
        tcpclient = new TcpClient(host, port);
-       tcpclient.connect(function() {
+       tcpclient.connect(function(resultCode) {
+               if (resultCode < 0) {
+                       update_ui('error', resultCode);
+                       return;
+               }
+
                var mpc_sender = new TcpClientSender(tcpclient);
                tcpclient.addResponseListener(tramp_mpc_recv);
                mpc = new Mpc(mpc_sender, update_ui);
@@ -301,6 +306,7 @@ function update_ui(state, cmd) {
                ui_mpc_status.innerText = ({
                        'disconnect': 'Disconnecting...',
                        'init': 'Connecting...',
+                       'error': 'Connection error ' + cmd,
                })[state];
                return;
        }
index 1ec8ed4b30cff76e7b76632b63bad4e5afff739c..762fcef8382bbb986d56ac87eabf311d8b92405d 100644 (file)
@@ -2,7 +2,7 @@
   "manifest_version": 2,
   "minimum_chrome_version": "24",
   "name": "Music Player Client",
-  "version": "3.1",
+  "version": "3.2",
   "description": "Control a Music Player Daemon (MPD)",
   "icons": {
     "128": "images/icon-128x128.png"