App-SocialCalc-Multiplayer
view release on metacpan or search on metacpan
socialcalc/third-party/Socket.IO-node/support/socket.io-client/socket.io.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;
})();
/**
* socket.io-node-client
* Copyright(c) 2011 LearnBoost <dev@learnboost.com>
* MIT Licensed
*/
(function(){
var io = this.io,
/**
* The WebSocket transport uses the HTML5 WebSocket API to establish an persistent
* connection with the Socket.IO server. This transport will also be inherited by the
* FlashSocket fallback as it provides a API compatible polyfill for the WebSockets.
*
* @constructor
* @extends {io.Transport}
* @api public
*/
WS = io.Transport.websocket = function(){
io.Transport.apply(this, arguments);
};
io.util.inherit(WS, io.Transport);
/**
* The transport type, you use this to identify which transport was chosen.
*
* @type {String}
( run in 1.137 second using v1.01-cache-2.11-cpan-39bf76dae61 )