code: function (obj) {
      this.debug("Received: %s", JSON.stringify(obj));
      if (typeof obj.event !== 'undefined') {
          this.debug("Received an event-based message, sending off to listeners");
          handleEvent.call(this, obj.event, obj.params);
      } else {
          if (this.waitingCallbacks.length > 0) {
              var callback = this.waitingCallbacks.shift();
              if (typeof callback === 'function') {
                  this.debug("Calling previously registered callback with message");
                  callback.call(this, obj);
              } else {
                  this.debug("Callback was a dummy, not calling");
              }
          } else {
              this.debug("No callbacks remaining, still received a response");
          }
      }
  }
docs: Receive a new message object from the server.
  Either we pass it off to the event-handler if it is an event-based object, or
  we look for a corresponding callback that is waiting for a response.
  @param  {Object} obj The received message as a javascript object