Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename code to closeCode #22

Merged
merged 4 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
README.html
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,20 @@ of an unclean close, otherwise it resolves to the code and reason sent by the
server.

```javascript
const { code, reason } = await wss.closed;
const { closeCode, reason } = await wss.closed;
```

An AbortSignal passed to the constructor makes it simple to abort the handshake.

```javascript
const controller = new AbortController();
const wss = new WebSocketStream(url, { signal: controller.signal });
setTimeout(() => controller.abort(), 1000);
const wss = new WebSocketStream(url, { signal: AbortSignal.timeout(1000) });
```

The close method can also be used to abort the handshake, but its main purpose
is to permit specifying the code and reason which is sent to the server.

```javascript
wss.close({code: 4000, reason: 'Game over'});
wss.close({closeCode: 4000, reason: 'Game over'});
```


Expand Down Expand Up @@ -156,11 +154,11 @@ errored.
sending Blobs adds considerable complexity to the implementation because the
contents are not available synchronously. Since less than 4% of sent messages
are Blobs it is better to avoid this complexity where we can.
* Changing, replacing or extending the underlying network protocol. A new API
based on QUIC called
[WebTransport](https://github.com/WICG/web-transport/blob/master/explainer.md)
is being discussed, and it is expected that new network capabilities will be
added there.
* Changing, replacing or extending the underlying network protocol.
[WebTransport](https://developer.mozilla.org/en-US/docs/Web/API/WebTransport)
has many advanced features that are not supported by the WebSocket protocol,
such as datagram support over UDP. It should be preferred when advanced
networking features are required.
* Allowing user JavaScript to select [WebSocket
extensions](https://tools.ietf.org/html/rfc6455#page-48). Since the server
already negotiates the extensions to use, adding additional controls to client
Expand Down Expand Up @@ -219,6 +217,9 @@ An older version of this explainer had the readable stream producing ArrayBuffer
chunks. This was changed to Uint8Array chunks to align better with WebTransport
and modern practice.

Previously the `closeCode` attribute was called `code`, but this conflicted with
the `code` attribute of `DOMException`.


## Future work

Expand Down