Quatrix JavaSctipt APIs
Space shortcuts
Quatrix JavaSctipt APIs QJA
Skip to end of metadata
Go to start of metadata

Allows to manage background jobs.

Parameters 

 

Name TypeDescription

cb

required

function

callback function

id

required

string 

l_m

optional

integer

last modified date

etag

optional

string

unique call indetificator

 

 

Example

this.mqReq = function( cb, id, l_m, etag ){ // l_m - last modified date
  var self = this;
  if( typeof token == 'undefined' ){
    throw new Error('Not authorized');
  }
  var headers = {};
  if( typeof l_m !== 'undefined'){
    headers['If-Modified-Since'] = l_m;
  } else {
    headers['If-Modified-Since'] = (new Date()).toUTCString();
  }
  if( typeof etag !== 'undefined'){
    headers['If-None-Match'] = etag;
  }
  this._mq = _requestFunction( url + '/mq/req' , 'GET', headers , {id : id}, function( xhr ){
    // Restart itself, except when aborted (status == 0)
    if (xhr.status) {
      if (xhr.status == 200) {
        timeout = 0;
      } else {
        timeout += 1000;
      }
      setTimeout(function(){
        return self.mqReq( cb, id, xhr.getResponseHeader('Last-Modified'), xhr.getResponseHeader('Etag') );
      }, timeout);
    }
    cb( xhr );
  });
  return this._mq;
};

 

 

  • No labels
Write a comment…
Quatrix JavaSctipt APIs QJA