libcurl.js/client/fragments/wisp_support.js
2024-10-03 07:59:35 -04:00

23 lines
560 B
JavaScript

/* REPLACE
ws ?= ?new WebSocketConstructor\(url, ?opts\)
*/
try {
let transport;
if (api.transport === "wisp") {
transport = new WispWebSocket(url);
}
else if (api.transport === "wsproxy") {
transport = new WebSocket(url);
}
else if (typeof api.transport === "string") {
throw new TypeError("invalid transport type");
}
else { //custom transports
transport = new api.transport(url);
}
ws = new tls_shim.ReclaimTLSSocket(url, transport);
}
catch (e) {
error_msg("Error while creating a TCP connection: " + e);
throw e;
}