aboutsummaryrefslogtreecommitdiffstats
path: root/signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transports
diff options
context:
space:
mode:
Diffstat (limited to 'signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transports')
-rw-r--r--signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transports/flashsocket.js254
-rw-r--r--signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transports/index.js62
-rw-r--r--signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transports/polling-jsonp.js221
-rw-r--r--signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transports/polling-xhr.js288
-rw-r--r--signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transports/polling.js210
-rw-r--r--signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transports/websocket.js158
6 files changed, 1193 insertions, 0 deletions
diff --git a/signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transports/flashsocket.js b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transports/flashsocket.js
new file mode 100644
index 0000000..9a5a108
--- /dev/null
+++ b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transports/flashsocket.js
@@ -0,0 +1,254 @@
+
+/**
+ * Module dependencies.
+ */
+
+var WS = require('./websocket')
+ , util = require('../util')
+ , debug = require('debug')('engine.io-client:flashsocket');
+
+/**
+ * Module exports.
+ */
+
+module.exports = FlashWS;
+
+/**
+ * Obfuscated key for Blue Coat.
+ */
+
+var xobject = global[['Active'].concat('Object').join('X')];
+
+/**
+ * FlashWS constructor.
+ *
+ * @api public
+ */
+
+function FlashWS (options) {
+ WS.call(this, options);
+ this.flashPath = options.flashPath;
+ this.policyPort = options.policyPort;
+};
+
+/**
+ * Inherits from WebSocket.
+ */
+
+util.inherits(FlashWS, WS);
+
+/**
+ * Transport name.
+ *
+ * @api public
+ */
+
+FlashWS.prototype.name = 'flashsocket';
+
+/**
+ * Opens the transport.
+ *
+ * @api public
+ */
+
+FlashWS.prototype.doOpen = function () {
+ if (!this.check()) {
+ // let the probe timeout
+ return;
+ }
+
+ // instrument websocketjs logging
+ function log (type) {
+ return function(){
+ var str = Array.prototype.join.call(arguments, ' ');
+ debug('[websocketjs %s] %s', type, str);
+ };
+ };
+
+ WEB_SOCKET_LOGGER = { log: log('debug'), error: log('error') };
+ WEB_SOCKET_SUPPRESS_CROSS_DOMAIN_SWF_ERROR = true;
+ WEB_SOCKET_DISABLE_AUTO_INITIALIZATION = true;
+
+ if ('undefined' == typeof WEB_SOCKET_SWF_LOCATION) {
+ WEB_SOCKET_SWF_LOCATION = this.flashPath + 'WebSocketMainInsecure.swf';
+ }
+
+ // dependencies
+ var deps = [this.flashPath + 'web_socket.js'];
+
+ if ('undefined' == typeof swfobject) {
+ deps.unshift(this.flashPath + 'swfobject.js');
+ }
+
+ var self = this;
+
+ load(deps, function () {
+ self.ready(function () {
+ WebSocket.__addTask(function () {
+ WS.prototype.doOpen.call(self);
+ });
+ });
+ });
+};
+
+/**
+ * Override to prevent closing uninitialized flashsocket.
+ *
+ * @api private
+ */
+
+FlashWS.prototype.doClose = function () {
+ if (!this.socket) return;
+ var self = this;
+ WebSocket.__addTask(function() {
+ WS.prototype.doClose.call(self);
+ });
+};
+
+/**
+ * Writes to the Flash socket.
+ *
+ * @api private
+ */
+
+FlashWS.prototype.write = function() {
+ var self = this, args = arguments;
+ WebSocket.__addTask(function () {
+ WS.prototype.write.apply(self, args);
+ });
+};
+
+/**
+ * Called upon dependencies are loaded.
+ *
+ * @api private
+ */
+
+FlashWS.prototype.ready = function (fn) {
+ if (typeof WebSocket == 'undefined' ||
+ !('__initialize' in WebSocket) || !swfobject) {
+ return;
+ }
+
+ if (swfobject.getFlashPlayerVersion().major < 10) {
+ return;
+ }
+
+ function init () {
+ // Only start downloading the swf file when the checked that this browser
+ // actually supports it
+ if (!FlashWS.loaded) {
+ if (843 != self.policyPort) {
+ WebSocket.loadFlashPolicyFile('xmlsocket://' + self.host + ':' + self.policyPort);
+ }
+
+ WebSocket.__initialize();
+ FlashWS.loaded = true;
+ }
+
+ fn.call(self);
+ }
+
+ var self = this;
+ if (document.body) {
+ return init();
+ }
+
+ util.load(init);
+};
+
+/**
+ * Feature detection for flashsocket.
+ *
+ * @return {Boolean} whether this transport is available.
+ * @api public
+ */
+
+FlashWS.prototype.check = function () {
+ if ('undefined' != typeof process) {
+ return false;
+ }
+
+ if (typeof WebSocket != 'undefined' && !('__initialize' in WebSocket)) {
+ return false;
+ }
+
+ if (xobject) {
+ var control = null;
+ try {
+ control = new xobject('ShockwaveFlash.ShockwaveFlash');
+ } catch (e) { }
+ if (control) {
+ return true;
+ }
+ } else {
+ for (var i = 0, l = navigator.plugins.length; i < l; i++) {
+ for (var j = 0, m = navigator.plugins[i].length; j < m; j++) {
+ if (navigator.plugins[i][j].description == 'Shockwave Flash') {
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+};
+
+/**
+ * Lazy loading of scripts.
+ * Based on $script by Dustin Diaz - MIT
+ */
+
+var scripts = {};
+
+/**
+ * Injects a script. Keeps tracked of injected ones.
+ *
+ * @param {String} path
+ * @param {Function} callback
+ * @api private
+ */
+
+function create (path, fn) {
+ if (scripts[path]) return fn();
+
+ var el = document.createElement('script');
+ var loaded = false;
+
+ debug('loading "%s"', path);
+ el.onload = el.onreadystatechange = function () {
+ if (loaded || scripts[path]) return;
+ var rs = el.readyState;
+ if (!rs || 'loaded' == rs || 'complete' == rs) {
+ debug('loaded "%s"', path);
+ el.onload = el.onreadystatechange = null;
+ loaded = true;
+ scripts[path] = true;
+ fn();
+ }
+ };
+
+ el.async = 1;
+ el.src = path;
+
+ var head = document.getElementsByTagName('head')[0];
+ head.insertBefore(el, head.firstChild);
+};
+
+/**
+ * Loads scripts and fires a callback.
+ *
+ * @param {Array} paths
+ * @param {Function} callback
+ */
+
+function load (arr, fn) {
+ function process (i) {
+ if (!arr[i]) return fn();
+ create(arr[i], function () {
+ process(++i);
+ });
+ };
+
+ process(0);
+};
diff --git a/signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transports/index.js b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transports/index.js
new file mode 100644
index 0000000..374620b
--- /dev/null
+++ b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transports/index.js
@@ -0,0 +1,62 @@
+
+/**
+ * Module dependencies
+ */
+
+var XHR = require('./polling-xhr')
+ , JSONP = require('./polling-jsonp')
+ , websocket = require('./websocket')
+ , flashsocket = require('./flashsocket')
+ , util = require('../util');
+
+/**
+ * Export transports.
+ */
+
+exports.polling = polling;
+exports.websocket = websocket;
+exports.flashsocket = flashsocket;
+
+/**
+ * Global reference.
+ */
+
+var global = 'undefined' != typeof window ? window : global;
+
+/**
+ * Polling transport polymorphic constructor.
+ * Decides on xhr vs jsonp based on feature detection.
+ *
+ * @api private
+ */
+
+function polling (opts) {
+ var xhr
+ , xd = false
+ , isXProtocol = false;
+
+ if (global.location) {
+ var isSSL = 'https:' == location.protocol;
+ var port = location.port;
+
+ // some user agents have empty `location.port`
+ if (Number(port) != port) {
+ port = isSSL ? 443 : 80;
+ }
+
+ xd = opts.host != location.hostname || port != opts.port;
+ isXProtocol = opts.secure != isSSL;
+ }
+
+ xhr = util.request(xd);
+ /* See #7 at http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx */
+ if (isXProtocol && global.XDomainRequest && xhr instanceof global.XDomainRequest) {
+ return new JSONP(opts);
+ }
+
+ if (xhr && !opts.forceJSONP) {
+ return new XHR(opts);
+ } else {
+ return new JSONP(opts);
+ }
+};
diff --git a/signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transports/polling-jsonp.js b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transports/polling-jsonp.js
new file mode 100644
index 0000000..fde3e79
--- /dev/null
+++ b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transports/polling-jsonp.js
@@ -0,0 +1,221 @@
+
+/**
+ * Module requirements.
+ */
+
+var Polling = require('./polling')
+ , util = require('../util');
+
+/**
+ * Module exports.
+ */
+
+module.exports = JSONPPolling;
+
+/**
+ * Global reference.
+ */
+
+var global = 'undefined' != typeof window ? window : global;
+
+/**
+ * Cached regular expressions.
+ */
+
+var rNewline = /\n/g;
+
+/**
+ * Global JSONP callbacks.
+ */
+
+var callbacks;
+
+/**
+ * Callbacks count.
+ */
+
+var index = 0;
+
+/**
+ * Noop.
+ */
+
+function empty () { }
+
+/**
+ * JSONP Polling constructor.
+ *
+ * @param {Object} opts.
+ * @api public
+ */
+
+function JSONPPolling (opts) {
+ Polling.call(this, opts);
+
+ // define global callbacks array if not present
+ // we do this here (lazily) to avoid unneeded global pollution
+ if (!callbacks) {
+ // we need to consider multiple engines in the same page
+ if (!global.___eio) global.___eio = [];
+ callbacks = global.___eio;
+ }
+
+ // callback identifier
+ this.index = callbacks.length;
+
+ // add callback to jsonp global
+ var self = this;
+ callbacks.push(function (msg) {
+ self.onData(msg);
+ });
+
+ // append to query string
+ this.query.j = this.index;
+};
+
+/**
+ * Inherits from Polling.
+ */
+
+util.inherits(JSONPPolling, Polling);
+
+/**
+ * Opens the socket.
+ *
+ * @api private
+ */
+
+JSONPPolling.prototype.doOpen = function () {
+ var self = this;
+ util.defer(function () {
+ Polling.prototype.doOpen.call(self);
+ });
+};
+
+/**
+ * Closes the socket
+ *
+ * @api private
+ */
+
+JSONPPolling.prototype.doClose = function () {
+ if (this.script) {
+ this.script.parentNode.removeChild(this.script);
+ this.script = null;
+ }
+
+ if (this.form) {
+ this.form.parentNode.removeChild(this.form);
+ this.form = null;
+ }
+
+ Polling.prototype.doClose.call(this);
+};
+
+/**
+ * Starts a poll cycle.
+ *
+ * @api private
+ */
+
+JSONPPolling.prototype.doPoll = function () {
+ var script = document.createElement('script');
+
+ if (this.script) {
+ this.script.parentNode.removeChild(this.script);
+ this.script = null;
+ }
+
+ script.async = true;
+ script.src = this.uri();
+
+ var insertAt = document.getElementsByTagName('script')[0];
+ insertAt.parentNode.insertBefore(script, insertAt);
+ this.script = script;
+
+ if (util.ua.gecko) {
+ setTimeout(function () {
+ var iframe = document.createElement('iframe');
+ document.body.appendChild(iframe);
+ document.body.removeChild(iframe);
+ }, 100);
+ }
+};
+
+/**
+ * Writes with a hidden iframe.
+ *
+ * @param {String} data to send
+ * @param {Function} called upon flush.
+ * @api private
+ */
+
+JSONPPolling.prototype.doWrite = function (data, fn) {
+ var self = this;
+
+ if (!this.form) {
+ var form = document.createElement('form')
+ , area = document.createElement('textarea')
+ , id = this.iframeId = 'eio_iframe_' + this.index
+ , iframe;
+
+ form.className = 'socketio';
+ form.style.position = 'absolute';
+ form.style.top = '-1000px';
+ form.style.left = '-1000px';
+ 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.uri();
+
+ function complete () {
+ initIframe();
+ fn();
+ };
+
+ 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();
+
+ // escape \n to prevent it from being converted into \r\n by some UAs
+ this.area.value = data.replace(rNewline, '\\n');
+
+ try {
+ this.form.submit();
+ } catch(e) {}
+
+ if (this.iframe.attachEvent) {
+ this.iframe.onreadystatechange = function(){
+ if (self.iframe.readyState == 'complete') {
+ complete();
+ }
+ };
+ } else {
+ this.iframe.onload = complete;
+ }
+};
diff --git a/signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transports/polling-xhr.js b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transports/polling-xhr.js
new file mode 100644
index 0000000..8e74c79
--- /dev/null
+++ b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transports/polling-xhr.js
@@ -0,0 +1,288 @@
+/**
+ * Module requirements.
+ */
+
+var Polling = require('./polling')
+ , util = require('../util')
+ , Emitter = require('../emitter')
+ , debug = require('debug')('engine.io-client:polling-xhr');
+
+/**
+ * Module exports.
+ */
+
+module.exports = XHR;
+module.exports.Request = Request;
+
+/**
+ * Global reference.
+ */
+
+var global = 'undefined' != typeof window ? window : global;
+
+/**
+ * Obfuscated key for Blue Coat.
+ */
+
+var xobject = global[['Active'].concat('Object').join('X')];
+
+/**
+ * Empty function
+ */
+
+function empty(){}
+
+/**
+ * XHR Polling constructor.
+ *
+ * @param {Object} opts
+ * @api public
+ */
+
+function XHR(opts){
+ Polling.call(this, opts);
+
+ if (global.location) {
+ this.xd = opts.host != global.location.hostname ||
+ global.location.port != opts.port;
+ }
+};
+
+/**
+ * Inherits from Polling.
+ */
+
+util.inherits(XHR, Polling);
+
+/**
+ * Opens the socket
+ *
+ * @api private
+ */
+
+XHR.prototype.doOpen = function(){
+ var self = this;
+ util.defer(function(){
+ Polling.prototype.doOpen.call(self);
+ });
+};
+
+/**
+ * Creates a request.
+ *
+ * @param {String} method
+ * @api private
+ */
+
+XHR.prototype.request = function(opts){
+ opts = opts || {};
+ opts.uri = this.uri();
+ opts.xd = this.xd;
+ return new Request(opts);
+};
+
+/**
+ * Sends data.
+ *
+ * @param {String} data to send.
+ * @param {Function} called upon flush.
+ * @api private
+ */
+
+XHR.prototype.doWrite = function(data, fn){
+ var req = this.request({ method: 'POST', data: data });
+ var self = this;
+ req.on('success', fn);
+ req.on('error', function(err){
+ self.onError('xhr post error', err);
+ });
+ this.sendXhr = req;
+};
+
+/**
+ * Starts a poll cycle.
+ *
+ * @api private
+ */
+
+XHR.prototype.doPoll = function(){
+ debug('xhr poll');
+ var req = this.request();
+ var self = this;
+ req.on('data', function(data){
+ self.onData(data);
+ });
+ req.on('error', function(err){
+ self.onError('xhr poll error', err);
+ });
+ this.pollXhr = req;
+};
+
+/**
+ * Request constructor
+ *
+ * @param {Object} options
+ * @api public
+ */
+
+function Request(opts){
+ this.method = opts.method || 'GET';
+ this.uri = opts.uri;
+ this.xd = !!opts.xd;
+ this.async = false !== opts.async;
+ this.data = undefined != opts.data ? opts.data : null;
+ this.create();
+}
+
+/**
+ * Mix in `Emitter`.
+ */
+
+Emitter(Request.prototype);
+
+/**
+ * Creates the XHR object and sends the request.
+ *
+ * @api private
+ */
+
+Request.prototype.create = function(){
+ var xhr = this.xhr = util.request(this.xd);
+ var self = this;
+
+ xhr.open(this.method, this.uri, this.async);
+
+ if ('POST' == this.method) {
+ try {
+ if (xhr.setRequestHeader) {
+ // xmlhttprequest
+ xhr.setRequestHeader('Content-type', 'text/plain;charset=UTF-8');
+ } else {
+ // xdomainrequest
+ xhr.contentType = 'text/plain';
+ }
+ } catch (e) {}
+ }
+
+ if (this.xd && global.XDomainRequest && xhr instanceof XDomainRequest) {
+ xhr.onerror = function(e){
+ self.onError(e);
+ };
+ xhr.onload = function(){
+ self.onData(xhr.responseText);
+ };
+ xhr.onprogress = empty;
+ } else {
+ // ie6 check
+ if ('withCredentials' in xhr) {
+ xhr.withCredentials = true;
+ }
+
+ xhr.onreadystatechange = function(){
+ var data;
+
+ try {
+ if (4 != xhr.readyState) return;
+ if (200 == xhr.status || 1223 == xhr.status) {
+ data = xhr.responseText;
+ } else {
+ self.onError(xhr.status);
+ }
+ } catch (e) {
+ self.onError(e);
+ }
+
+ if (undefined !== data) {
+ self.onData(data);
+ }
+ };
+ }
+
+ debug('sending xhr with url %s | data %s', this.uri, this.data);
+ xhr.send(this.data);
+
+ if (xobject) {
+ this.index = Request.requestsCount++;
+ Request.requests[this.index] = this;
+ }
+};
+
+/**
+ * Called upon successful response.
+ *
+ * @api private
+ */
+
+Request.prototype.onSuccess = function(){
+ this.emit('success');
+ this.cleanup();
+};
+
+/**
+ * Called if we have data.
+ *
+ * @api private
+ */
+
+Request.prototype.onData = function(data){
+ this.emit('data', data);
+ this.onSuccess();
+};
+
+/**
+ * Called upon error.
+ *
+ * @api private
+ */
+
+Request.prototype.onError = function(err){
+ this.emit('error', err);
+ this.cleanup();
+};
+
+/**
+ * Cleans up house.
+ *
+ * @api private
+ */
+
+Request.prototype.cleanup = function(){
+ // xmlhttprequest
+ this.xhr.onreadystatechange = empty;
+
+ // xdomainrequest
+ this.xhr.onload = this.xhr.onerror = empty;
+
+ try {
+ this.xhr.abort();
+ } catch(e) {}
+
+ if (xobject) {
+ delete Request.requests[this.index];
+ }
+
+ this.xhr = null;
+};
+
+/**
+ * Aborts the request.
+ *
+ * @api public
+ */
+
+Request.prototype.abort = function(){
+ this.cleanup();
+};
+
+if (xobject) {
+ Request.requestsCount = 0;
+ Request.requests = {};
+
+ global.attachEvent('onunload', function(){
+ for (var i in Request.requests) {
+ if (Request.requests.hasOwnProperty(i)) {
+ Request.requests[i].abort();
+ }
+ }
+ });
+}
diff --git a/signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transports/polling.js b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transports/polling.js
new file mode 100644
index 0000000..5550d5f
--- /dev/null
+++ b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transports/polling.js
@@ -0,0 +1,210 @@
+/**
+ * Module dependencies.
+ */
+
+var Transport = require('../transport')
+ , util = require('../util')
+ , parser = require('../parser')
+ , debug = require('debug')('engine.io-client:polling');
+
+/**
+ * Module exports.
+ */
+
+module.exports = Polling;
+
+/**
+ * Global reference.
+ */
+
+var global = 'undefined' != typeof window ? window : global;
+
+/**
+ * Polling interface.
+ *
+ * @param {Object} opts
+ * @api private
+ */
+
+function Polling(opts){
+ Transport.call(this, opts);
+}
+
+/**
+ * Inherits from Transport.
+ */
+
+util.inherits(Polling, Transport);
+
+/**
+ * Transport name.
+ */
+
+Polling.prototype.name = 'polling';
+
+/**
+ * Opens the socket (triggers polling). We write a PING message to determine
+ * when the transport is open.
+ *
+ * @api private
+ */
+
+Polling.prototype.doOpen = function(){
+ this.poll();
+};
+
+/**
+ * Pauses polling.
+ *
+ * @param {Function} callback upon buffers are flushed and transport is paused
+ * @api private
+ */
+
+Polling.prototype.pause = function(onPause){
+ var pending = 0;
+ var self = this;
+
+ this.readyState = 'pausing';
+
+ function pause(){
+ debug('paused');
+ self.readyState = 'paused';
+ onPause();
+ }
+
+ if (this.polling || !this.writable) {
+ var total = 0;
+
+ if (this.polling) {
+ debug('we are currently polling - waiting to pause');
+ total++;
+ this.once('pollComplete', function(){
+ debug('pre-pause polling complete');
+ --total || pause();
+ });
+ }
+
+ if (!this.writable) {
+ debug('we are currently writing - waiting to pause');
+ total++;
+ this.once('drain', function(){
+ debug('pre-pause writing complete');
+ --total || pause();
+ });
+ }
+ } else {
+ pause();
+ }
+};
+
+/**
+ * Starts polling cycle.
+ *
+ * @api public
+ */
+
+Polling.prototype.poll = function(){
+ debug('polling');
+ this.polling = true;
+ this.doPoll();
+ this.emit('poll');
+};
+
+/**
+ * Overloads onData to detect payloads.
+ *
+ * @api private
+ */
+
+Polling.prototype.onData = function(data){
+ debug('polling got data %s', data);
+ // decode payload
+ var packets = parser.decodePayload(data);
+
+ for (var i = 0, l = packets.length; i < l; i++) {
+ // if its the first message we consider the trnasport open
+ if ('opening' == this.readyState) {
+ this.onOpen();
+ }
+
+ // if its a close packet, we close the ongoing requests
+ if ('close' == packets[i].type) {
+ this.onClose();
+ return;
+ }
+
+ // otherwise bypass onData and handle the message
+ this.onPacket(packets[i]);
+ }
+
+ // if we got data we're not polling
+ this.polling = false;
+ this.emit('pollComplete');
+
+ if ('open' == this.readyState) {
+ this.poll();
+ } else {
+ debug('ignoring poll - transport state "%s"', this.readyState);
+ }
+};
+
+/**
+ * For polling, send a close packet.
+ *
+ * @api private
+ */
+
+Polling.prototype.doClose = function(){
+ debug('sending close packet');
+ this.send([{ type: 'close' }]);
+};
+
+/**
+ * Writes a packets payload.
+ *
+ * @param {Array} data packets
+ * @param {Function} drain callback
+ * @api private
+ */
+
+Polling.prototype.write = function(packets){
+ var self = this;
+ this.writable = false;
+ this.doWrite(parser.encodePayload(packets), function(){
+ self.writable = true;
+ self.emit('drain');
+ });
+};
+
+/**
+ * Generates uri for connection.
+ *
+ * @api private
+ */
+
+Polling.prototype.uri = function(){
+ var query = this.query || {};
+ var schema = this.secure ? 'https' : 'http';
+ var port = '';
+
+ // cache busting is forced for IE / android / iOS6 ಠ_ಠ
+ if (global.ActiveXObject || util.ua.android || util.ua.ios6
+ || this.timestampRequests) {
+ query[this.timestampParam] = +new Date;
+ }
+
+ query = util.qs(query);
+
+ // avoid port if default for schema
+ if (this.port && (('https' == schema && this.port != 443)
+ || ('http' == schema && this.port != 80))) {
+ port = ':' + this.port;
+ }
+
+ // prepend ? to query
+ if (query.length) {
+ query = '?' + query;
+ }
+
+ return schema + '://' + this.host + port + this.path + query;
+};
diff --git a/signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transports/websocket.js b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transports/websocket.js
new file mode 100644
index 0000000..1bf055d
--- /dev/null
+++ b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transports/websocket.js
@@ -0,0 +1,158 @@
+
+/**
+ * Module dependencies.
+ */
+
+var Transport = require('../transport')
+ , parser = require('../parser')
+ , util = require('../util')
+ , debug = require('debug')('engine.io-client:websocket');
+
+/**
+ * Module exports.
+ */
+
+module.exports = WS;
+
+/**
+ * Global reference.
+ */
+
+var global = 'undefined' != typeof window ? window : global;
+
+/**
+ * WebSocket transport constructor.
+ *
+ * @api {Object} connection options
+ * @api public
+ */
+
+function WS(opts){
+ Transport.call(this, opts);
+};
+
+/**
+ * Inherits from Transport.
+ */
+
+util.inherits(WS, Transport);
+
+/**
+ * Transport name.
+ *
+ * @api public
+ */
+
+WS.prototype.name = 'websocket';
+
+/**
+ * Opens socket.
+ *
+ * @api private
+ */
+
+WS.prototype.doOpen = function(){
+ if (!this.check()) {
+ // let probe timeout
+ return;
+ }
+
+ var self = this;
+
+ this.socket = new (ws())(this.uri());
+ this.socket.onopen = function(){
+ self.onOpen();
+ };
+ this.socket.onclose = function(){
+ self.onClose();
+ };
+ this.socket.onmessage = function(ev){
+ self.onData(ev.data);
+ };
+ this.socket.onerror = function(e){
+ self.onError('websocket error', e);
+ };
+};
+
+/**
+ * Writes data to socket.
+ *
+ * @param {Array} array of packets.
+ * @api private
+ */
+
+WS.prototype.write = function(packets){
+ for (var i = 0, l = packets.length; i < l; i++) {
+ this.socket.send(parser.encodePacket(packets[i]));
+ }
+};
+
+/**
+ * Closes socket.
+ *
+ * @api private
+ */
+
+WS.prototype.doClose = function(){
+ if (typeof this.socket !== 'undefined') {
+ this.socket.close();
+ }
+};
+
+/**
+ * Generates uri for connection.
+ *
+ * @api private
+ */
+
+WS.prototype.uri = function(){
+ var query = this.query || {};
+ var schema = this.secure ? 'wss' : 'ws';
+ var port = '';
+
+ // avoid port if default for schema
+ if (this.port && (('wss' == schema && this.port != 443)
+ || ('ws' == schema && this.port != 80))) {
+ port = ':' + this.port;
+ }
+
+ // append timestamp to URI
+ if (this.timestampRequests) {
+ query[this.timestampParam] = +new Date;
+ }
+
+ query = util.qs(query);
+
+ // prepend ? to query
+ if (query.length) {
+ query = '?' + query;
+ }
+
+ return schema + '://' + this.host + port + this.path + query;
+};
+
+/**
+ * Feature detection for WebSocket.
+ *
+ * @return {Boolean} whether this transport is available.
+ * @api public
+ */
+
+WS.prototype.check = function(){
+ var websocket = ws();
+ return !!websocket && !('__initialize' in websocket && this.name === WS.prototype.name);
+};
+
+/**
+ * Getter for WS constructor.
+ *
+ * @api private
+ */
+
+function ws(){
+ if ('undefined' != typeof process) {
+ return require('ws');
+ }
+
+ return global.WebSocket || global.MozWebSocket;
+}