App-SocialCalc-Multiplayer
view release on metacpan or search on metacpan
socialcalc/third-party/Socket.IO-node/support/socket.io-client/lib/transports/xhr.js view on Meta::CPAN
if (status == 200){
self.checkSend();
} else {
self.onDisconnect();
}
}
};
this.sendXHR.send('data=' + encodeURIComponent(data));
};
/**
* Disconnect the established connection.
*
* @returns {Transport}.
* @api public
*/
XHR.prototype.disconnect = function(){
// send disconnection signal
this.onDisconnect();
return this;
};
/**
* Handle the disconnect request.
*
* @api private
*/
XHR.prototype.onDisconnect = function(){
if (this.xhr){
this.xhr.onreadystatechange = empty;
try {
this.xhr.abort();
} catch(e){}
this.xhr = null;
}
if (this.sendXHR){
this.sendXHR.onreadystatechange = empty;
try {
this.sendXHR.abort();
} catch(e){}
this.sendXHR = null;
}
this.sendBuffer = [];
io.Transport.prototype.onDisconnect.call(this);
};
/**
* Generates a configured XHR request
*
* @param {String} url The url that needs to be requested.
* @param {String} method The method the request should use.
* @param {Boolean} multipart Do a multipart XHR request
* @returns {XMLHttpRequest}
* @api private
*/
XHR.prototype.request = function(url, method, multipart){
var req = request(this.base.isXDomain());
if (multipart) req.multipart = true;
req.open(method || 'GET', this.prepareUrl() + (url ? '/' + url : ''));
if (method == 'POST' && 'setRequestHeader' in req){
req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=utf-8');
}
return req;
};
/**
* Check if the XHR transports are supported
*
* @param {Boolean} xdomain Check if we support cross domain requests.
* @returns {Boolean}
* @api public
*/
XHR.check = function(xdomain){
try {
if (request(xdomain)) return true;
} catch(e){}
return false;
};
/**
* Check if the XHR transport supports corss domain requests.
*
* @returns {Boolean}
* @api public
*/
XHR.xdomainCheck = function(){
return XHR.check(true);
};
XHR.request = request;
})();
( run in 1.737 second using v1.01-cache-2.11-cpan-39bf76dae61 )