diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f8b246..c1245b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Libcurl.js Changelog: +## v0.6.3 (3/20/24): +- Fix an error during websocket cleanup + ## v0.6.1 (3/20/24): - Fix NPM package exports diff --git a/README.md b/README.md index 8a599fa..d9aa4d6 100644 --- a/README.md +++ b/README.md @@ -155,7 +155,7 @@ The `CurlWebSocket.send` function can be used to send data to the websocket. The You can call `CurlWebSocket.close` to close and clean up the websocket. ```js -let ws = new libcurl.CurlWebSocket("wss://echo.websocket.org", [], {verbose: 1}); +let ws = new libcurl.CurlWebSocket("wss://echo.websocket.in/", [], {verbose: 1}); ws.onopen = () => { console.log("ws connected!"); ws.send("hello".repeat(100)); @@ -167,7 +167,7 @@ ws.onmessage = (data) => { You can also use the `libcurl.WebSocket` object, which works identically to the regular [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) object. It uses the same arguments as the simpler `CurlWebSocket` API. ```js -let ws = new libcurl.WebSocket("wss://echo.websocket.org"); +let ws = new libcurl.WebSocket("wss://echo.websocket.in/"); ws.addEventListener("open", () => { console.log("ws connected!"); ws.send("hello".repeat(128)); diff --git a/client/javascript/main.js b/client/javascript/main.js index 37f2efb..1e09b6d 100644 --- a/client/javascript/main.js +++ b/client/javascript/main.js @@ -106,7 +106,7 @@ api = { WispConnection: WispConnection, transport: "wisp", - WebSocket: WebSocket, + WebSocket: FakeWebSocket, CurlWebSocket: CurlWebSocket, TLSSocket: TLSSocket, HTTPSession: HTTPSession, diff --git a/client/javascript/session.js b/client/javascript/session.js index 1c4948f..bac98aa 100644 --- a/client/javascript/session.js +++ b/client/javascript/session.js @@ -132,7 +132,7 @@ class CurlSession { catch (e) { //the readable stream has been closed elsewhere, so cancel the request if (e instanceof TypeError) { - finish_callback(-1); + end_callback(-1); } else { throw e; diff --git a/client/javascript/websocket.js b/client/javascript/websocket.js index 9e95dc6..e371582 100644 --- a/client/javascript/websocket.js +++ b/client/javascript/websocket.js @@ -107,7 +107,7 @@ class CurlWebSocket extends CurlSession { cleanup(error=0) { if (this.http_handle) { - this.remove_handle(this.http_handle); + this.remove_request(this.http_handle); this.http_handle = null; super.close(); } diff --git a/client/package.json b/client/package.json index 7d4186d..8940462 100644 --- a/client/package.json +++ b/client/package.json @@ -1,6 +1,6 @@ { "name": "libcurl.js", - "version": "0.6.1", + "version": "0.6.3", "description": "An experimental port of libcurl to WebAssembly for use in the browser.", "main": "libcurl.mjs", "exports": { diff --git a/client/tests/scripts/test_websocket.js b/client/tests/scripts/test_websocket.js index 4a10cf3..23d6bc0 100644 --- a/client/tests/scripts/test_websocket.js +++ b/client/tests/scripts/test_websocket.js @@ -1,8 +1,8 @@ function test() { - let message_len = 128*1024; + let message_len = 1024; return new Promise((resolve, reject) => { - let ws = new libcurl.WebSocket("wss://echo.websocket.org"); + let ws = new libcurl.WebSocket("wss://echo.websocket.in/"); ws.addEventListener("open", () => { ws.send("hello".repeat(message_len)); }); @@ -12,8 +12,8 @@ function test() { messages += 1; if (messages >= 2) { if (event.data !== "hello".repeat(message_len)) reject("unexpected response"); - if (messages >= 11) resolve(); - ws.send("hello".repeat(message_len)); + else if (messages >= 11) resolve(); + else ws.send("hello".repeat(message_len)); } });