aboutsummaryrefslogtreecommitdiffstats
path: root/signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/transports
diff options
context:
space:
mode:
authorlookshe <github@lookshe.org>2015-03-14 20:45:20 +0100
committerlookshe <github@lookshe.org>2015-03-14 20:45:20 +0100
commitb60df56157ee1fd0bd4938799bac05a62fda91a1 (patch)
tree2bc906c45ff9ec940e07f9676f5ed34ddd4ae022 /signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/transports
initial commit from working version
Diffstat (limited to 'signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/transports')
-rw-r--r--signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/transports/flashsocket.js191
-rw-r--r--signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/transports/htmlfile.js173
-rw-r--r--signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/transports/jsonp-polling.js256
-rw-r--r--signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/transports/websocket.js197
-rw-r--r--signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/transports/xhr-polling.js177
-rw-r--r--signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/transports/xhr.js217
6 files changed, 1211 insertions, 0 deletions
diff --git a/signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/transports/flashsocket.js b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/transports/flashsocket.js
new file mode 100644
index 0000000..a1c29fa
--- /dev/null
+++ b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/transports/flashsocket.js
@@ -0,0 +1,191 @@
+
+/**
+ * socket.io
+ * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
+ * MIT Licensed
+ */
+
+(function (exports, io) {
+
+ /**
+ * Expose constructor.
+ */
+
+ exports.flashsocket = Flashsocket;
+
+ /**
+ * The FlashSocket transport. This is a API wrapper for the HTML5 WebSocket
+ * specification. It uses a .swf file to communicate with the server. If you want
+ * to serve the .swf file from a other server than where the Socket.IO script is
+ * coming from you need to use the insecure version of the .swf. More information
+ * about this can be found on the github page.
+ *
+ * @constructor
+ * @extends {io.Transport.websocket}
+ * @api public
+ */
+
+ function Flashsocket () {
+ io.Transport.websocket.apply(this, arguments);
+ };
+
+ /**
+ * Inherits from Transport.
+ */
+
+ io.util.inherit(Flashsocket, io.Transport.websocket);
+
+ /**
+ * Transport name
+ *
+ * @api public
+ */
+
+ Flashsocket.prototype.name = 'flashsocket';
+
+ /**
+ * Disconnect the established `FlashSocket` connection. This is done by adding a
+ * new task to the FlashSocket. The rest will be handled off by the `WebSocket`
+ * transport.
+ *
+ * @returns {Transport}
+ * @api public
+ */
+
+ Flashsocket.prototype.open = function () {
+ var self = this
+ , args = arguments;
+
+ WebSocket.__addTask(function () {
+ io.Transport.websocket.prototype.open.apply(self, args);
+ });
+ return this;
+ };
+
+ /**
+ * Sends a message to the Socket.IO server. This is done by adding a new
+ * task to the FlashSocket. The rest will be handled off by the `WebSocket`
+ * transport.
+ *
+ * @returns {Transport}
+ * @api public
+ */
+
+ Flashsocket.prototype.send = function () {
+ var self = this, args = arguments;
+ WebSocket.__addTask(function () {
+ io.Transport.websocket.prototype.send.apply(self, args);
+ });
+ return this;
+ };
+
+ /**
+ * Disconnects the established `FlashSocket` connection.
+ *
+ * @returns {Transport}
+ * @api public
+ */
+
+ Flashsocket.prototype.close = function () {
+ WebSocket.__tasks.length = 0;
+ io.Transport.websocket.prototype.close.call(this);
+ return this;
+ };
+
+ /**
+ * The WebSocket fall back needs to append the flash container to the body
+ * element, so we need to make sure we have access to it. Or defer the call
+ * until we are sure there is a body element.
+ *
+ * @param {Socket} socket The socket instance that needs a transport
+ * @param {Function} fn The callback
+ * @api private
+ */
+
+ Flashsocket.prototype.ready = function (socket, fn) {
+ function init () {
+ var options = socket.options
+ , port = options['flash policy port']
+ , path = [
+ 'http' + (options.secure ? 's' : '') + ':/'
+ , options.host + ':' + options.port
+ , options.resource
+ , 'static/flashsocket'
+ , 'WebSocketMain' + (socket.isXDomain() ? 'Insecure' : '') + '.swf'
+ ];
+
+ // Only start downloading the swf file when the checked that this browser
+ // actually supports it
+ if (!Flashsocket.loaded) {
+ if (typeof WEB_SOCKET_SWF_LOCATION === 'undefined') {
+ // Set the correct file based on the XDomain settings
+ WEB_SOCKET_SWF_LOCATION = path.join('/');
+ }
+
+ if (port !== 843) {
+ WebSocket.loadFlashPolicyFile('xmlsocket://' + options.host + ':' + port);
+ }
+
+ WebSocket.__initialize();
+ Flashsocket.loaded = true;
+ }
+
+ fn.call(self);
+ }
+
+ var self = this;
+ if (document.body) return init();
+
+ io.util.load(init);
+ };
+
+ /**
+ * Check if the FlashSocket transport is supported as it requires that the Adobe
+ * Flash Player plug-in version `10.0.0` or greater is installed. And also check if
+ * the polyfill is correctly loaded.
+ *
+ * @returns {Boolean}
+ * @api public
+ */
+
+ Flashsocket.check = function () {
+ if (
+ typeof WebSocket == 'undefined'
+ || !('__initialize' in WebSocket) || !swfobject
+ ) return false;
+
+ return swfobject.getFlashPlayerVersion().major >= 10;
+ };
+
+ /**
+ * Check if the FlashSocket transport can be used as cross domain / cross origin
+ * transport. Because we can't see which type (secure or insecure) of .swf is used
+ * we will just return true.
+ *
+ * @returns {Boolean}
+ * @api public
+ */
+
+ Flashsocket.xdomainCheck = function () {
+ return true;
+ };
+
+ /**
+ * Disable AUTO_INITIALIZATION
+ */
+
+ if (typeof window != 'undefined') {
+ WEB_SOCKET_DISABLE_AUTO_INITIALIZATION = true;
+ }
+
+ /**
+ * Add the transport to your public io.transports array.
+ *
+ * @api private
+ */
+
+ io.transports.push('flashsocket');
+})(
+ 'undefined' != typeof io ? io.Transport : module.exports
+ , 'undefined' != typeof io ? io : module.parent.exports
+);
diff --git a/signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/transports/htmlfile.js b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/transports/htmlfile.js
new file mode 100644
index 0000000..367c4c1
--- /dev/null
+++ b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/transports/htmlfile.js
@@ -0,0 +1,173 @@
+/**
+ * socket.io
+ * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
+ * MIT Licensed
+ */
+
+(function (exports, io) {
+
+ /**
+ * Expose constructor.
+ */
+
+ exports.htmlfile = HTMLFile;
+
+ /**
+ * The HTMLFile transport creates a `forever iframe` based transport
+ * for Internet Explorer. Regular forever iframe implementations will
+ * continuously trigger the browsers buzy indicators. If the forever iframe
+ * is created inside a `htmlfile` these indicators will not be trigged.
+ *
+ * @constructor
+ * @extends {io.Transport.XHR}
+ * @api public
+ */
+
+ function HTMLFile (socket) {
+ io.Transport.XHR.apply(this, arguments);
+ };
+
+ /**
+ * Inherits from XHR transport.
+ */
+
+ io.util.inherit(HTMLFile, io.Transport.XHR);
+
+ /**
+ * Transport name
+ *
+ * @api public
+ */
+
+ HTMLFile.prototype.name = 'htmlfile';
+
+ /**
+ * Creates a new ActiveX `htmlfile` with a forever loading iframe
+ * that can be used to listen to messages. Inside the generated
+ * `htmlfile` a reference will be made to the HTMLFile transport.
+ *
+ * @api private
+ */
+
+ HTMLFile.prototype.get = function () {
+ this.doc = new ActiveXObject('htmlfile');
+ this.doc.open();
+ this.doc.write('<html></html>');
+ this.doc.close();
+ this.doc.parentWindow.s = this;
+
+ var iframeC = this.doc.createElement('div');
+ iframeC.className = 'socketio';
+
+ this.doc.body.appendChild(iframeC);
+ this.iframe = this.doc.createElement('iframe');
+
+ iframeC.appendChild(this.iframe);
+
+ var self = this
+ , query = io.util.query(this.socket.options.query, 't='+ +new Date);
+
+ this.iframe.src = this.prepareUrl() + query;
+
+ io.util.on(window, 'unload', function () {
+ self.destroy();
+ });
+ };
+
+ /**
+ * The Socket.IO server will write script tags inside the forever
+ * iframe, this function will be used as callback for the incoming
+ * information.
+ *
+ * @param {String} data The message
+ * @param {document} doc Reference to the context
+ * @api private
+ */
+
+ HTMLFile.prototype._ = function (data, doc) {
+ // unescape all forward slashes. see GH-1251
+ data = data.replace(/\\\//g, '/');
+ this.onData(data);
+ try {
+ var script = doc.getElementsByTagName('script')[0];
+ script.parentNode.removeChild(script);
+ } catch (e) { }
+ };
+
+ /**
+ * Destroy the established connection, iframe and `htmlfile`.
+ * And calls the `CollectGarbage` function of Internet Explorer
+ * to release the memory.
+ *
+ * @api private
+ */
+
+ HTMLFile.prototype.destroy = function () {
+ if (this.iframe){
+ try {
+ this.iframe.src = 'about:blank';
+ } catch(e){}
+
+ this.doc = null;
+ this.iframe.parentNode.removeChild(this.iframe);
+ this.iframe = null;
+
+ CollectGarbage();
+ }
+ };
+
+ /**
+ * Disconnects the established connection.
+ *
+ * @returns {Transport} Chaining.
+ * @api public
+ */
+
+ HTMLFile.prototype.close = function () {
+ this.destroy();
+ return io.Transport.XHR.prototype.close.call(this);
+ };
+
+ /**
+ * Checks if the browser supports this transport. The browser
+ * must have an `ActiveXObject` implementation.
+ *
+ * @return {Boolean}
+ * @api public
+ */
+
+ HTMLFile.check = function (socket) {
+ if (typeof window != "undefined" && 'ActiveXObject' in window){
+ try {
+ var a = new ActiveXObject('htmlfile');
+ return a && io.Transport.XHR.check(socket);
+ } catch(e){}
+ }
+ return false;
+ };
+
+ /**
+ * Check if cross domain requests are supported.
+ *
+ * @returns {Boolean}
+ * @api public
+ */
+
+ HTMLFile.xdomainCheck = function () {
+ // we can probably do handling for sub-domains, we should
+ // test that it's cross domain but a subdomain here
+ return false;
+ };
+
+ /**
+ * Add the transport to your public io.transports array.
+ *
+ * @api private
+ */
+
+ io.transports.push('htmlfile');
+
+})(
+ 'undefined' != typeof io ? io.Transport : module.exports
+ , 'undefined' != typeof io ? io : module.parent.exports
+);
diff --git a/signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/transports/jsonp-polling.js b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/transports/jsonp-polling.js
new file mode 100644
index 0000000..a97047f
--- /dev/null
+++ b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/transports/jsonp-polling.js
@@ -0,0 +1,256 @@
+
+/**
+ * socket.io
+ * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
+ * MIT Licensed
+ */
+
+(function (exports, io, global) {
+ /**
+ * There is a way to hide the loading indicator in Firefox. If you create and
+ * remove a iframe it will stop showing the current loading indicator.
+ * Unfortunately we can't feature detect that and UA sniffing is evil.
+ *
+ * @api private
+ */
+
+ var indicator = global.document && "MozAppearance" in
+ global.document.documentElement.style;
+
+ /**
+ * Expose constructor.
+ */
+
+ exports['jsonp-polling'] = JSONPPolling;
+
+ /**
+ * The JSONP transport creates an persistent connection by dynamically
+ * inserting a script tag in the page. This script tag will receive the
+ * information of the Socket.IO server. When new information is received
+ * it creates a new script tag for the new data stream.
+ *
+ * @constructor
+ * @extends {io.Transport.xhr-polling}
+ * @api public
+ */
+
+ function JSONPPolling (socket) {
+ io.Transport['xhr-polling'].apply(this, arguments);
+
+ this.index = io.j.length;
+
+ var self = this;
+
+ io.j.push(function (msg) {
+ self._(msg);
+ });
+ };
+
+ /**
+ * Inherits from XHR polling transport.
+ */
+
+ io.util.inherit(JSONPPolling, io.Transport['xhr-polling']);
+
+ /**
+ * Transport name
+ *
+ * @api public
+ */
+
+ JSONPPolling.prototype.name = 'jsonp-polling';
+
+ /**
+ * Posts a encoded message to the Socket.IO server using an iframe.
+ * The iframe is used because script tags can create POST based requests.
+ * The iframe is positioned outside of the view so the user does not
+ * notice it's existence.
+ *
+ * @param {String} data A encoded message.
+ * @api private
+ */
+
+ JSONPPolling.prototype.post = function (data) {
+ var self = this
+ , query = io.util.query(
+ this.socket.options.query
+ , 't='+ (+new Date) + '&i=' + this.index
+ );
+
+ if (!this.form) {
+ var form = document.createElement('form')
+ , area = document.createElement('textarea')
+ , id = this.iframeId = 'socketio_iframe_' + this.index
+ , iframe;
+
+ form.className = 'socketio';
+ form.style.position = 'absolute';
+ form.style.top = '0px';
+ form.style.left = '0px';
+ form.style.display = 'none';
+ form.target = id;
+ form.method = 'POST';
+ form.setAttribute('accept-charset', 'utf-8');
+ area.name = 'd';
+ form.appendChild(area);
+ document.body.appendChild(form);
+
+ this.form = form;
+ this.area = area;
+ }
+
+ this.form.action = this.prepareUrl() + query;
+
+ function complete () {
+ initIframe();
+ self.socket.setBuffer(false);
+ };
+
+ function initIframe () {
+ if (self.iframe) {
+ self.form.removeChild(self.iframe);
+ }
+
+ try {
+ // ie6 dynamic iframes with target="" support (thanks Chris Lambacher)
+ iframe = document.createElement('<iframe name="'+ self.iframeId +'">');
+ } catch (e) {
+ iframe = document.createElement('iframe');
+ iframe.name = self.iframeId;
+ }
+
+ iframe.id = self.iframeId;
+
+ self.form.appendChild(iframe);
+ self.iframe = iframe;
+ };
+
+ initIframe();
+
+ // we temporarily stringify until we figure out how to prevent
+ // browsers from turning `\n` into `\r\n` in form inputs
+ this.area.value = io.JSON.stringify(data);
+
+ try {
+ this.form.submit();
+ } catch(e) {}
+
+ if (this.iframe.attachEvent) {
+ iframe.onreadystatechange = function () {
+ if (self.iframe.readyState == 'complete') {
+ complete();
+ }
+ };
+ } else {
+ this.iframe.onload = complete;
+ }
+
+ this.socket.setBuffer(true);
+ };
+
+ /**
+ * Creates a new JSONP poll that can be used to listen
+ * for messages from the Socket.IO server.
+ *
+ * @api private
+ */
+
+ JSONPPolling.prototype.get = function () {
+ var self = this
+ , script = document.createElement('script')
+ , query = io.util.query(
+ this.socket.options.query
+ , 't='+ (+new Date) + '&i=' + this.index
+ );
+
+ if (this.script) {
+ this.script.parentNode.removeChild(this.script);
+ this.script = null;
+ }
+
+ script.async = true;
+ script.src = this.prepareUrl() + query;
+ script.onerror = function () {
+ self.onClose();
+ };
+
+ var insertAt = document.getElementsByTagName('script')[0];
+ insertAt.parentNode.insertBefore(script, insertAt);
+ this.script = script;
+
+ if (indicator) {
+ setTimeout(function () {
+ var iframe = document.createElement('iframe');
+ document.body.appendChild(iframe);
+ document.body.removeChild(iframe);
+ }, 100);
+ }
+ };
+
+ /**
+ * Callback function for the incoming message stream from the Socket.IO server.
+ *
+ * @param {String} data The message
+ * @api private
+ */
+
+ JSONPPolling.prototype._ = function (msg) {
+ this.onData(msg);
+ if (this.isOpen) {
+ this.get();
+ }
+ return this;
+ };
+
+ /**
+ * The indicator hack only works after onload
+ *
+ * @param {Socket} socket The socket instance that needs a transport
+ * @param {Function} fn The callback
+ * @api private
+ */
+
+ JSONPPolling.prototype.ready = function (socket, fn) {
+ var self = this;
+ if (!indicator) return fn.call(this);
+
+ io.util.load(function () {
+ fn.call(self);
+ });
+ };
+
+ /**
+ * Checks if browser supports this transport.
+ *
+ * @return {Boolean}
+ * @api public
+ */
+
+ JSONPPolling.check = function () {
+ return 'document' in global;
+ };
+
+ /**
+ * Check if cross domain requests are supported
+ *
+ * @returns {Boolean}
+ * @api public
+ */
+
+ JSONPPolling.xdomainCheck = function () {
+ return true;
+ };
+
+ /**
+ * Add the transport to your public io.transports array.
+ *
+ * @api private
+ */
+
+ io.transports.push('jsonp-polling');
+
+})(
+ 'undefined' != typeof io ? io.Transport : module.exports
+ , 'undefined' != typeof io ? io : module.parent.exports
+ , this
+);
diff --git a/signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/transports/websocket.js b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/transports/websocket.js
new file mode 100644
index 0000000..b2c55ff
--- /dev/null
+++ b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/transports/websocket.js
@@ -0,0 +1,197 @@
+
+/**
+ * socket.io
+ * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
+ * MIT Licensed
+ */
+
+(function (exports, io, global) {
+
+ /**
+ * Expose constructor.
+ */
+
+ exports.websocket = WS;
+
+ /**
+ * 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
+ */
+
+ function WS (socket) {
+ io.Transport.apply(this, arguments);
+ };
+
+ /**
+ * Inherits from Transport.
+ */
+
+ io.util.inherit(WS, io.Transport);
+
+ /**
+ * Transport name
+ *
+ * @api public
+ */
+
+ WS.prototype.name = 'websocket';
+
+ /**
+ * Initializes a new `WebSocket` connection with the Socket.IO server. We attach
+ * all the appropriate listeners to handle the responses from the server.
+ *
+ * @returns {Transport}
+ * @api public
+ */
+
+ WS.prototype.open = function () {
+ var query = io.util.query(this.socket.options.query)
+ , self = this
+ , Socket
+
+ // if node
+ Socket = require('ws');
+ // end node
+
+ if (!Socket) {
+ Socket = global.MozWebSocket || global.WebSocket;
+ }
+
+ this.websocket = new Socket(this.prepareUrl() + query);
+
+ this.websocket.onopen = function () {
+ self.onOpen();
+ self.socket.setBuffer(false);
+ };
+ this.websocket.onmessage = function (ev) {
+ self.onData(ev.data);
+ };
+ this.websocket.onclose = function () {
+ self.onClose();
+ self.socket.setBuffer(true);
+ };
+ this.websocket.onerror = function (e) {
+ self.onError(e);
+ };
+
+ return this;
+ };
+
+ /**
+ * Send a message to the Socket.IO server. The message will automatically be
+ * encoded in the correct message format.
+ *
+ * @returns {Transport}
+ * @api public
+ */
+
+ // Do to a bug in the current IDevices browser, we need to wrap the send in a
+ // setTimeout, when they resume from sleeping the browser will crash if
+ // we don't allow the browser time to detect the socket has been closed
+ if (io.util.ua.iDevice) {
+ WS.prototype.send = function (data) {
+ var self = this;
+ setTimeout(function() {
+ self.websocket.send(data);
+ },0);
+ return this;
+ };
+ } else {
+ WS.prototype.send = function (data) {
+ this.websocket.send(data);
+ return this;
+ };
+ }
+
+ /**
+ * Payload
+ *
+ * @api private
+ */
+
+ WS.prototype.payload = function (arr) {
+ for (var i = 0, l = arr.length; i < l; i++) {
+ this.packet(arr[i]);
+ }
+ return this;
+ };
+
+ /**
+ * Disconnect the established `WebSocket` connection.
+ *
+ * @returns {Transport}
+ * @api public
+ */
+
+ WS.prototype.close = function () {
+ this.websocket.close();
+ return this;
+ };
+
+ /**
+ * Handle the errors that `WebSocket` might be giving when we
+ * are attempting to connect or send messages.
+ *
+ * @param {Error} e The error.
+ * @api private
+ */
+
+ WS.prototype.onError = function (e) {
+ this.socket.onError(e);
+ };
+
+ /**
+ * Returns the appropriate scheme for the URI generation.
+ *
+ * @api private
+ */
+ WS.prototype.scheme = function () {
+ return this.socket.options.secure ? 'wss' : 'ws';
+ };
+
+ /**
+ * Checks if the browser has support for native `WebSockets` and that
+ * it's not the polyfill created for the FlashSocket transport.
+ *
+ * @return {Boolean}
+ * @api public
+ */
+
+ WS.check = function () {
+ // if node
+ return true;
+ // end node
+ return ('WebSocket' in global && !('__addTask' in WebSocket))
+ || 'MozWebSocket' in global;
+ };
+
+ /**
+ * Check if the `WebSocket` transport support cross domain communications.
+ *
+ * @returns {Boolean}
+ * @api public
+ */
+
+ WS.xdomainCheck = function () {
+ return true;
+ };
+
+ /**
+ * Add the transport to your public io.transports array.
+ *
+ * @api private
+ */
+
+ io.transports.push('websocket');
+
+})(
+ 'undefined' != typeof io ? io.Transport : module.exports
+ , 'undefined' != typeof io ? io : module.parent.exports
+ , this
+);
diff --git a/signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/transports/xhr-polling.js b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/transports/xhr-polling.js
new file mode 100644
index 0000000..0decb6b
--- /dev/null
+++ b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/transports/xhr-polling.js
@@ -0,0 +1,177 @@
+
+/**
+ * socket.io
+ * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
+ * MIT Licensed
+ */
+
+(function (exports, io, global) {
+
+ /**
+ * Expose constructor.
+ */
+
+ exports['xhr-polling'] = XHRPolling;
+
+ /**
+ * The XHR-polling transport uses long polling XHR requests to create a
+ * "persistent" connection with the server.
+ *
+ * @constructor
+ * @api public
+ */
+
+ function XHRPolling () {
+ io.Transport.XHR.apply(this, arguments);
+ };
+
+ /**
+ * Inherits from XHR transport.
+ */
+
+ io.util.inherit(XHRPolling, io.Transport.XHR);
+
+ /**
+ * Merge the properties from XHR transport
+ */
+
+ io.util.merge(XHRPolling, io.Transport.XHR);
+
+ /**
+ * Transport name
+ *
+ * @api public
+ */
+
+ XHRPolling.prototype.name = 'xhr-polling';
+
+ /**
+ * Indicates whether heartbeats is enabled for this transport
+ *
+ * @api private
+ */
+
+ XHRPolling.prototype.heartbeats = function () {
+ return false;
+ };
+
+ /**
+ * Establish a connection, for iPhone and Android this will be done once the page
+ * is loaded.
+ *
+ * @returns {Transport} Chaining.
+ * @api public
+ */
+
+ XHRPolling.prototype.open = function () {
+ var self = this;
+
+ io.Transport.XHR.prototype.open.call(self);
+ return false;
+ };
+
+ /**
+ * Starts a XHR request to wait for incoming messages.
+ *
+ * @api private
+ */
+
+ function empty () {};
+
+ XHRPolling.prototype.get = function () {
+ if (!this.isOpen) return;
+
+ var self = this;
+
+ function stateChange () {
+ if (this.readyState == 4) {
+ this.onreadystatechange = empty;
+
+ if (this.status == 200) {
+ self.onData(this.responseText);
+ self.get();
+ } else {
+ self.onClose();
+ }
+ }
+ };
+
+ function onload () {
+ this.onload = empty;
+ this.onerror = empty;
+ self.retryCounter = 1;
+ self.onData(this.responseText);
+ self.get();
+ };
+
+ function onerror () {
+ self.retryCounter ++;
+ if(!self.retryCounter || self.retryCounter > 3) {
+ self.onClose();
+ } else {
+ self.get();
+ }
+ };
+
+ this.xhr = this.request();
+
+ if (global.XDomainRequest && this.xhr instanceof XDomainRequest) {
+ this.xhr.onload = onload;
+ this.xhr.onerror = onerror;
+ } else {
+ this.xhr.onreadystatechange = stateChange;
+ }
+
+ this.xhr.send(null);
+ };
+
+ /**
+ * Handle the unclean close behavior.
+ *
+ * @api private
+ */
+
+ XHRPolling.prototype.onClose = function () {
+ io.Transport.XHR.prototype.onClose.call(this);
+
+ if (this.xhr) {
+ this.xhr.onreadystatechange = this.xhr.onload = this.xhr.onerror = empty;
+ try {
+ this.xhr.abort();
+ } catch(e){}
+ this.xhr = null;
+ }
+ };
+
+ /**
+ * Webkit based browsers show a infinit spinner when you start a XHR request
+ * before the browsers onload event is called so we need to defer opening of
+ * the transport until the onload event is called. Wrapping the cb in our
+ * defer method solve this.
+ *
+ * @param {Socket} socket The socket instance that needs a transport
+ * @param {Function} fn The callback
+ * @api private
+ */
+
+ XHRPolling.prototype.ready = function (socket, fn) {
+ var self = this;
+
+ io.util.defer(function () {
+ fn.call(self);
+ });
+ };
+
+ /**
+ * Add the transport to your public io.transports array.
+ *
+ * @api private
+ */
+
+ io.transports.push('xhr-polling');
+
+})(
+ 'undefined' != typeof io ? io.Transport : module.exports
+ , 'undefined' != typeof io ? io : module.parent.exports
+ , this
+);
diff --git a/signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/transports/xhr.js b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/transports/xhr.js
new file mode 100644
index 0000000..0625905
--- /dev/null
+++ b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/transports/xhr.js
@@ -0,0 +1,217 @@
+
+/**
+ * socket.io
+ * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
+ * MIT Licensed
+ */
+
+(function (exports, io, global) {
+
+ /**
+ * Expose constructor.
+ *
+ * @api public
+ */
+
+ exports.XHR = XHR;
+
+ /**
+ * XHR constructor
+ *
+ * @costructor
+ * @api public
+ */
+
+ function XHR (socket) {
+ if (!socket) return;
+
+ io.Transport.apply(this, arguments);
+ this.sendBuffer = [];
+ };
+
+ /**
+ * Inherits from Transport.
+ */
+
+ io.util.inherit(XHR, io.Transport);
+
+ /**
+ * Establish a connection
+ *
+ * @returns {Transport}
+ * @api public
+ */
+
+ XHR.prototype.open = function () {
+ this.socket.setBuffer(false);
+ this.onOpen();
+ this.get();
+
+ // we need to make sure the request succeeds since we have no indication
+ // whether the request opened or not until it succeeded.
+ this.setCloseTimeout();
+
+ return this;
+ };
+
+ /**
+ * Check if we need to send data to the Socket.IO server, if we have data in our
+ * buffer we encode it and forward it to the `post` method.
+ *
+ * @api private
+ */
+
+ XHR.prototype.payload = function (payload) {
+ var msgs = [];
+
+ for (var i = 0, l = payload.length; i < l; i++) {
+ msgs.push(io.parser.encodePacket(payload[i]));
+ }
+
+ this.send(io.parser.encodePayload(msgs));
+ };
+
+ /**
+ * Send data to the Socket.IO server.
+ *
+ * @param data The message
+ * @returns {Transport}
+ * @api public
+ */
+
+ XHR.prototype.send = function (data) {
+ this.post(data);
+ return this;
+ };
+
+ /**
+ * Posts a encoded message to the Socket.IO server.
+ *
+ * @param {String} data A encoded message.
+ * @api private
+ */
+
+ function empty () { };
+
+ XHR.prototype.post = function (data) {
+ var self = this;
+ this.socket.setBuffer(true);
+
+ function stateChange () {
+ if (this.readyState == 4) {
+ this.onreadystatechange = empty;
+ self.posting = false;
+
+ if (this.status == 200){
+ self.socket.setBuffer(false);
+ } else {
+ self.onClose();
+ }
+ }
+ }
+
+ function onload () {
+ this.onload = empty;
+ self.socket.setBuffer(false);
+ };
+
+ this.sendXHR = this.request('POST');
+
+ if (global.XDomainRequest && this.sendXHR instanceof XDomainRequest) {
+ this.sendXHR.onload = this.sendXHR.onerror = onload;
+ } else {
+ this.sendXHR.onreadystatechange = stateChange;
+ }
+
+ this.sendXHR.send(data);
+ };
+
+ /**
+ * Disconnects the established `XHR` connection.
+ *
+ * @returns {Transport}
+ * @api public
+ */
+
+ XHR.prototype.close = function () {
+ this.onClose();
+ return 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.
+ * @returns {XMLHttpRequest}
+ * @api private
+ */
+
+ XHR.prototype.request = function (method) {
+ var req = io.util.request(this.socket.isXDomain())
+ , query = io.util.query(this.socket.options.query, 't=' + +new Date);
+
+ req.open(method || 'GET', this.prepareUrl() + query, true);
+
+ if (method == 'POST') {
+ try {
+ if (req.setRequestHeader) {
+ req.setRequestHeader('Content-type', 'text/plain;charset=UTF-8');
+ } else {
+ // XDomainRequest
+ req.contentType = 'text/plain';
+ }
+ } catch (e) {}
+ }
+
+ return req;
+ };
+
+ /**
+ * Returns the scheme to use for the transport URLs.
+ *
+ * @api private
+ */
+
+ XHR.prototype.scheme = function () {
+ return this.socket.options.secure ? 'https' : 'http';
+ };
+
+ /**
+ * Check if the XHR transports are supported
+ *
+ * @param {Boolean} xdomain Check if we support cross domain requests.
+ * @returns {Boolean}
+ * @api public
+ */
+
+ XHR.check = function (socket, xdomain) {
+ try {
+ var request = io.util.request(xdomain),
+ usesXDomReq = (global.XDomainRequest && request instanceof XDomainRequest),
+ socketProtocol = (socket && socket.options && socket.options.secure ? 'https:' : 'http:'),
+ isXProtocol = (global.location && socketProtocol != global.location.protocol);
+ if (request && !(usesXDomReq && isXProtocol)) {
+ return true;
+ }
+ } catch(e) {}
+
+ return false;
+ };
+
+ /**
+ * Check if the XHR transport supports cross domain requests.
+ *
+ * @returns {Boolean}
+ * @api public
+ */
+
+ XHR.xdomainCheck = function (socket) {
+ return XHR.check(socket, true);
+ };
+
+})(
+ 'undefined' != typeof io ? io.Transport : module.exports
+ , 'undefined' != typeof io ? io : module.parent.exports
+ , this
+);