llHidGnubby.prototype.destroy = function() {
if (!this.dev) return; // Already dead.
+ this.gnubbies_.removeOpenDevice(
+ {namespace: llHidGnubby.NAMESPACE, device: this.id});
this.closing = true;
console.log(UTIL_fmt('llHidGnubby.destroy()'));
var dev = this.dev;
this.dev = null;
- var self = this;
-
- function onClosed() {
+ chrome.hid.disconnect(dev.connectionId, function() {
console.log(UTIL_fmt('Device ' + dev.handle + ' closed'));
- self.gnubbies_.removeOpenDevice(
- {namespace: llHidGnubby.NAMESPACE, device: self.id});
- }
-
- chrome.hid.disconnect(dev.connectionId, onClosed);
+ });
};
/**
};
/**
- * @return {boolean} whether this device is open and ready to use.
- * @private
- */
-llHidGnubby.prototype.readyToUse_ = function() {
- if (this.closing) return false;
- if (!this.dev) return false;
-
- return true;
-};
-
-/**
* Register a client for this gnubby.
* @param {*} who The client.
*/
* If queue was empty, initiate the write.
* @param {number} cid The client's channel ID.
* @param {number} cmd The command to send.
- * @param {ArrayBuffer} data Command arguments
+ * @param {ArrayBuffer|Uint8Array} data Command arguments
*/
llHidGnubby.prototype.queueCommand = function(cid, cmd, data) {
if (!this.dev) return;