lib/harmonyclient.js
function request (command, body, expectedResponseType, canHandleStanzaPredicate) {
  debug('request with command "' + command + '" with body ' + body)

  var deferred = Q.defer()
  var iq = buildCommandIqStanza(command, body)
  var id = iq.attr('id')

  expectedResponseType = expectedResponseType || 'encoded'
  canHandleStanzaPredicate = canHandleStanzaPredicate || defaultCanHandleStanzaPredicate.bind(null, id)

  this._responseHandlerQueue.push({
    canHandleStanza: canHandleStanzaPredicate,		 deferred: deferred,		 responseType: expectedResponseType
  })

  this._xmppClient.send(iq)

  return deferred.promise
}
function request (command, body, expectedResponseType, canHandleStanzaPredicate) {
  debug('request with command "' + command + '" with body ' + body)

  var deferred = Q.defer()
  var iq = buildCommandIqStanza(command, body)
  var id = iq.attr('id')

  expectedResponseType = expectedResponseType || 'encoded'
  canHandleStanzaPredicate = canHandleStanzaPredicate || defaultCanHandleStanzaPredicate.bind(null, id)

  this._responseHandlerQueue.push({
    canHandleStanza: canHandleStanzaPredicate,		 deferred: deferred,		 responseType: expectedResponseType
  })

  this._xmppClient.send(iq)

  return deferred.promise
}
function request ( command , body , expectedResponseType , canHandleStanzaPredicate ) { debug ( 'request with command "' + command + '" with body ' + body ) var deferred = Q . defer ( ) var iq = buildCommandIqStanza ( command , body ) var id = iq . attr ( 'id' ) expectedResponseType = expectedResponseType || 'encoded' canHandleStanzaPredicate = canHandleStanzaPredicate || defaultCanHandleStanzaPredicate . bind ( null , id ) this . _responseHandlerQueue . push ( { canHandleStanza : canHandleStanzaPredicate , deferred : deferred , responseType : expectedResponseType } ) this . _xmppClient . send ( iq ) return deferred . promise }
Sends a command with the given body to the hub. The returned promise gets resolved as soon as a response for this
very request arrives.

By specifying expectedResponseType with either "json" or "encoded", you advice the response stanza handler how you
expect the responses data encoding. See the protocol guide for further information.

The cnaHandleStanzaFn parameter allows to define a predicate to determine if an incoming stanza is the response to
your request. This can be handy if a generic stateDigest message might be the acknowledgment to your initial
request.
*
@param command
@param body
@param expectedResponseType
@param canHandleStanzaPredicate
@returns {Q.Promise}
Sends a command with the given body to the hub . The returned promise gets resolved as soon as a response for this very request arrives .