]> cgit.babelmonkeys.de Git - adhocweb.git/commitdiff
More robust fetching of features
authorFlorian Zeitz <florob@babelmonkeys.de>
Wed, 6 Oct 2010 21:49:29 +0000 (23:49 +0200)
committerFlorian Zeitz <florob@babelmonkeys.de>
Wed, 6 Oct 2010 21:49:29 +0000 (23:49 +0200)
* Only request items if adhoc feature is present
* Implement errback

js/main.js

index 6bd32412743739166210a6cc07f5d3c9e3df1a29..c03a8cf74c391428363da43a2f1269f1fb40d9c3 100644 (file)
@@ -1,5 +1,5 @@
 var BOSH_SERVICE = 'http://localhost:5280/http-bind/';
 var BOSH_SERVICE = 'http://localhost:5280/http-bind/';
-var show_log = false;
+var show_log = true;
 
 Strophe.addNamespace("ADHOC", "http://jabber.org/protocol/commands");
 
 
 Strophe.addNamespace("ADHOC", "http://jabber.org/protocol/commands");
 
@@ -260,15 +260,20 @@ function getCommandNodes() {
 
 function checkFeatures() {
     featureIQ = $iq({ type: "get", to: queryJID, id: "features1" }).c("query", {xmlns: Strophe.NS.DISCO_INFO});
 
 function checkFeatures() {
     featureIQ = $iq({ type: "get", to: queryJID, id: "features1" }).c("query", {xmlns: Strophe.NS.DISCO_INFO});
-    connection.sendIQ(featureIQ, function(result) {
-        if ($(result).find("feature[var='" + Strophe.NS.ADHOC + "']").length > 0) {
-            $('#output').append("<p>This entitiy does support AdHoc commands</p>");
-        } else {
-            $('#output').append("<p>This entitiy does NOT support AdHoc commands</p>");
-        }
-    });
     $('#output').empty();
     $('#output').empty();
-    getCommandNodes();
+    connection.sendIQ(featureIQ,
+        function(result) { /* Callback */
+                if ($(result).find("feature[var='" + Strophe.NS.ADHOC + "']").length > 0) {
+                    $('#output').append("<p>This entitiy does support AdHoc commands</p>");
+                    getCommandNodes();
+                } else {
+                    $('#output').append("<p>This entitiy does NOT support AdHoc commands</p>");
+                }
+        },
+        function(result) { /* Errback */
+            $('#output').append("<p>Couldn't get list of supported features</p>");
+        }
+    );
 }
 
 function showConnect() {
 }
 
 function showConnect() {