log errors when creating connections and add npm export for bundled version

This commit is contained in:
ading2210 2024-03-20 14:02:54 -04:00
parent 2c04f55a5e
commit b374d02e48
4 changed files with 31 additions and 13 deletions

View file

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