()
| 2018 | var failed = false; |
| 2019 | Socket.priorWebsocketSuccess = false; |
| 2020 | var onTransportOpen = function onTransportOpen() { |
| 2021 | if (failed) return; |
| 2022 | transport.send([{ |
| 2023 | type: "ping", |
| 2024 | data: "probe" |
| 2025 | }]); |
| 2026 | transport.once("packet", function (msg) { |
| 2027 | if (failed) return; |
| 2028 | if ("pong" === msg.type && "probe" === msg.data) { |
| 2029 | _this4.upgrading = true; |
| 2030 | _this4.emitReserved("upgrading", transport); |
| 2031 | if (!transport) return; |
| 2032 | Socket.priorWebsocketSuccess = "websocket" === transport.name; |
| 2033 | _this4.transport.pause(function () { |
| 2034 | if (failed) return; |
| 2035 | if ("closed" === _this4.readyState) return; |
| 2036 | cleanup(); |
| 2037 | _this4.setTransport(transport); |
| 2038 | transport.send([{ |
| 2039 | type: "upgrade" |
| 2040 | }]); |
| 2041 | _this4.emitReserved("upgrade", transport); |
| 2042 | transport = null; |
| 2043 | _this4.upgrading = false; |
| 2044 | _this4.flush(); |
| 2045 | }); |
| 2046 | } else { |
| 2047 | var err = new Error("probe error"); |
| 2048 | // @ts-ignore |
| 2049 | err.transport = transport.name; |
| 2050 | _this4.emitReserved("upgradeError", err); |
| 2051 | } |
| 2052 | }); |
| 2053 | }; |
| 2054 | function freezeTransport() { |
| 2055 | if (failed) return; |
| 2056 | // Any callback called by transport should be ignored since now |
nothing calls this directly
no test coverage detected