In readBinaryElement, added argument allowNull, and use for ContentObject content.
This fixes some of the connection problems where the initial response from a new hub would not decode.
diff --git a/js/encoding/BinaryXMLDecoder.js b/js/encoding/BinaryXMLDecoder.js
index 4556c57..882a7fc 100644
--- a/js/encoding/BinaryXMLDecoder.js
+++ b/js/encoding/BinaryXMLDecoder.js
@@ -344,9 +344,11 @@
//long
startTag,
//TreeMap<String, String>
- attributes){
+ attributes,
+ //boolean
+ allowNull){
this.readStartElement(startTag, attributes);
- return this.readBlob();
+ return this.readBlob(allowNull);
};
@@ -378,8 +380,17 @@
};
-// Read a blob as well as the end element. Returns a Uint8Array.
-BinaryXMLDecoder.prototype.readBlob = function() {
+/*
+ * Read a blob as well as the end element. Returns a Uint8Array (or null for missing blob).
+ * If the blob is missing and allowNull is false (default), throw an exception. Otherwise,
+ * just read the end element and return null.
+ */
+BinaryXMLDecoder.prototype.readBlob = function(allowNull) {
+ if (this.istream[this.offset] == XML_CLOSE && allowNull) {
+ this.readEndElement();
+ return null;
+ }
+
var blob = this.decodeBlob();
this.readEndElement();
return blob;