From 9ba3402321b224b65cc3eed994b6cb016cfeabda Mon Sep 17 00:00:00 2001 From: Florian Zeitz Date: Wed, 6 Oct 2010 23:49:29 +0200 Subject: [PATCH] More robust fetching of features * Only request items if adhoc feature is present * Implement errback --- js/main.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/js/main.js b/js/main.js index 6bd3241..c03a8cf 100644 --- a/js/main.js +++ b/js/main.js @@ -1,5 +1,5 @@ var BOSH_SERVICE = 'http://localhost:5280/http-bind/'; -var show_log = false; +var show_log = true; 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}); - connection.sendIQ(featureIQ, function(result) { - if ($(result).find("feature[var='" + Strophe.NS.ADHOC + "']").length > 0) { - $('#output').append("

This entitiy does support AdHoc commands

"); - } else { - $('#output').append("

This entitiy does NOT support AdHoc commands

"); - } - }); $('#output').empty(); - getCommandNodes(); + connection.sendIQ(featureIQ, + function(result) { /* Callback */ + if ($(result).find("feature[var='" + Strophe.NS.ADHOC + "']").length > 0) { + $('#output').append("

This entitiy does support AdHoc commands

"); + getCommandNodes(); + } else { + $('#output').append("

This entitiy does NOT support AdHoc commands

"); + } + }, + function(result) { /* Errback */ + $('#output').append("

Couldn't get list of supported features

"); + } + ); } function showConnect() { -- 2.39.2