aboutsummaryrefslogtreecommitdiffstats
path: root/signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transport.js
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/transport.js')
-rw-r--r--signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transport.js141
1 files changed, 141 insertions, 0 deletions
diff --git a/signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transport.js b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transport.js
new file mode 100644
index 0000000..5760f84
--- /dev/null
+++ b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/components/learnboost-engine.io-client/lib/transport.js
@@ -0,0 +1,141 @@
+
+/**
+ * Module dependencies.
+ */
+
+var util = require('./util')
+ , parser = require('./parser')
+ , Emitter = require('./emitter');
+
+/**
+ * Module exports.
+ */
+
+module.exports = Transport;
+
+/**
+ * Transport abstract constructor.
+ *
+ * @param {Object} options.
+ * @api private
+ */
+
+function Transport (opts) {
+ this.path = opts.path;
+ this.host = opts.host;
+ this.port = opts.port;
+ this.secure = opts.secure;
+ this.query = opts.query;
+ this.timestampParam = opts.timestampParam;
+ this.timestampRequests = opts.timestampRequests;
+ this.readyState = '';
+};
+
+/**
+ * Mix in `Emitter`.
+ */
+
+Emitter(Transport.prototype);
+
+/**
+ * Emits an error.
+ *
+ * @param {String} str
+ * @return {Transport} for chaining
+ * @api public
+ */
+
+Transport.prototype.onError = function (msg, desc) {
+ var err = new Error(msg);
+ err.type = 'TransportError';
+ err.description = desc;
+ this.emit('error', err);
+ return this;
+};
+
+/**
+ * Opens the transport.
+ *
+ * @api public
+ */
+
+Transport.prototype.open = function () {
+ if ('closed' == this.readyState || '' == this.readyState) {
+ this.readyState = 'opening';
+ this.doOpen();
+ }
+
+ return this;
+};
+
+/**
+ * Closes the transport.
+ *
+ * @api private
+ */
+
+Transport.prototype.close = function () {
+ if ('opening' == this.readyState || 'open' == this.readyState) {
+ this.doClose();
+ this.onClose();
+ }
+
+ return this;
+};
+
+/**
+ * Sends multiple packets.
+ *
+ * @param {Array} packets
+ * @api private
+ */
+
+Transport.prototype.send = function(packets){
+ if ('open' == this.readyState) {
+ this.write(packets);
+ } else {
+ throw new Error('Transport not open');
+ }
+};
+
+/**
+ * Called upon open
+ *
+ * @api private
+ */
+
+Transport.prototype.onOpen = function () {
+ this.readyState = 'open';
+ this.writable = true;
+ this.emit('open');
+};
+
+/**
+ * Called with data.
+ *
+ * @param {String} data
+ * @api private
+ */
+
+Transport.prototype.onData = function (data) {
+ this.onPacket(parser.decodePacket(data));
+};
+
+/**
+ * Called with a decoded packet.
+ */
+
+Transport.prototype.onPacket = function (packet) {
+ this.emit('packet', packet);
+};
+
+/**
+ * Called upon close.
+ *
+ * @api private
+ */
+
+Transport.prototype.onClose = function () {
+ this.readyState = 'closed';
+ this.emit('close');
+};