function Socket(uri) {
            var _this;

            var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

            _classCallCheck(this, Socket);

            _this = _super.call(this);
            _this.writeBuffer = [];

            if (uri && "object" === _typeof(uri)) {
                opts = uri;
                uri = null;
            }

            if (uri) {
                uri = parse(uri);
                opts.hostname = uri.host;
                opts.secure = uri.protocol === "https" || uri.protocol === "wss";
                opts.port = uri.port;
                if (uri.query) opts.query = uri.query;
            } else if (opts.host) {
                opts.hostname = parse(opts.host).host;
            }

            installTimerFunctions(_assertThisInitialized(_this), opts);
            _this.secure = null != opts.secure ? opts.secure : typeof location !== "undefined" && "https:" === location.protocol;

            if (opts.hostname && !opts.port) {
                // if no port is specified manually, use the protocol default
                opts.port = _this.secure ? "443" : "80";
            }

            _this.hostname = opts.hostname || (typeof location !== "undefined" ? location.hostname : "localhost");
            _this.port = opts.port || (typeof location !== "undefined" && location.port ? location.port : _this.secure ? "443" : "80");
            _this.transports = opts.transports || ["polling", "websocket"];
            _this.writeBuffer = [];
            _this.prevBufferLen = 0;
            _this.opts = _extends(
                {
                    path: "/engine.io",
                    agent: false,
                    withCredentials: false,
                    upgrade: true,
                    timestampParam: "t",
                    rememberUpgrade: false,
                    addTrailingSlash: true,
                    rejectUnauthorized: true,
                    perMessageDeflate: {
                        threshold: 1024,
                    },
                    transportOptions: {},
                    closeOnBeforeunload: true,
                },
                opts
            );
            _this.opts.path = _this.opts.path.replace(/\/$/, "") + (_this.opts.addTrailingSlash ? "/" : "");

            if (typeof _this.opts.query === "string") {
                _this.opts.query = decode(_this.opts.query);
            } // set on handshake

            _this.id = null;
            _this.upgrades = null;
            _this.pingInterval = null;
            _this.pingTimeout = null; // set on heartbeat

            _this.pingTimeoutTimer = null;

            if (typeof addEventListener === "function") {
                if (_this.opts.closeOnBeforeunload) {
                    // Firefox closes the connection when the "beforeunload" event is emitted but not Chrome. This event listener
                    // ensures every browser behaves the same (no "disconnect" event at the Socket.IO level when the page is
                    // closed/reloaded)
                    _this.beforeunloadEventListener = function () {
                        if (_this.transport) {
                            // silently close the transport
                            _this.transport.removeAllListeners();

                            _this.transport.close();
                        }
                    };

                    addEventListener("beforeunload", _this.beforeunloadEventListener, false);
                }

                if (_this.hostname !== "localhost") {
                    _this.offlineEventListener = function () {
                        _this.onClose("transport close", {
                            description: "network connection lost",
                        });
                    };

                    addEventListener("offline", _this.offlineEventListener, false);
                }
            }

            _this.open();

            return _this;
        }
Socket constructor.

@param {String|Object} uri - uri or options
@param {Object} opts - options