Skip to content

Commit 1f74a07

Browse files
committed
Update k6/experimental/websockets for v0.54.0
1 parent b869090 commit 1f74a07

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

docs/sources/next/javascript-api/k6-experimental/websockets/_index.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: 'websockets'
3-
description: "k6 websockets experimental API"
3+
description: 'k6 websockets experimental API'
44
weight: 05
55
---
66

@@ -16,31 +16,31 @@ A global event loop lets a single VU have multiple concurrent connections, which
1616
The `WebSocket API` is not fully implemented, and we're working on it, but we believe it's usable for most users. So whether you're writing a new WebSocket test, or currently using the `k6/ws` module, we invite you to give it a try, and report any issues in the project's [issue tracker](https://github.com/grafana/xk6-websockets/). Our midterm goal is to make this module part of k6 core, and long-term to replace the [`k6/ws`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-ws) module.
1717

1818
| Class/Method | Description |
19-
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
19+
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
2020
| [Params](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/params) | Used for setting various WebSocket connection parameters such as headers, cookie jar, compression, etc. |
2121
| [WebSocket(url, protocols, params)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket) | Constructs a new WebSocket connection. |
2222
| [WebSocket.close()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-close) | Close the WebSocket connection. |
2323
| [WebSocket.ping()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-ping) | Send a ping. |
24-
| [WebSocket.send(data)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-send) | Send string data. |
24+
| [WebSocket.send(data)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-send) | Send data. |
2525
| [WebSocket.addEventListener(event, handler)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-addeventlistener) | Add an event listener on the connection for specific event. |
2626
| [Blob](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/blob) | Interface that represents a blob, which is a file-like object of immutable, raw data; they can be read as text or binary data, or converted into a [ReadableStream](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/streams/readablestream). |
2727

2828
A WebSocket instance also has the following properties:
2929

3030
<!-- vale off -->
3131

32-
| Class/Property | Description |
33-
|-----------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
34-
| WebSocket.readyState | The current state of the connection. Could be one of [the four states](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/readyState). |
35-
| WebSocket.url | The URL of the connection as resolved by the constructor. |
36-
| WebSocket.bufferedAmount | The number of bytes of data that have been queued using calls to `send()` but not yet transmitted to the network. |
37-
| WebSocket.binaryType | _Required_. The [`binaryType`](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/binaryType) controls the type of binary data being received over the WebSocket connection. Use `"blob"` to receive it as `Blob`, or `"arraybuffer"` to receive it as `ArrayBuffer`. The default value is empty. That will change to default to `"blob"` in the future. If you want to keep the same behavior, we recommend setting it to `"arraybuffer"`. |
38-
| [WebSocket.onmessage](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-onmessage) | A handler for `message` events. |
39-
| [WebSocket.onerror](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-onerror) | A handler for `error` events. |
40-
| [WebSocket.onopen](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-onopen) | A handler for `open` events. |
41-
| [WebSocket.onclose](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-onclose) | A handler for `close` events. |
42-
| [WebSocket.onping](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-onping) | A handler for `ping` events. |
43-
| [WebSocket.onpong](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-onpong) | A handler for `pong` events. |
32+
| Class/Property | Description |
33+
| --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
34+
| WebSocket.readyState | The current state of the connection. Could be one of [the four states](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/readyState). |
35+
| WebSocket.url | The URL of the connection as resolved by the constructor. |
36+
| WebSocket.bufferedAmount | The number of bytes of data that have been queued using calls to `send()` but not yet transmitted to the network. |
37+
| WebSocket.binaryType | The [`binaryType`](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/binaryType) controls the type of binary data being received over the WebSocket connection. Use `"blob"` to receive it as `Blob`, or `"arraybuffer"` to receive it as `ArrayBuffer`. The default value is `"blob"`. |
38+
| [WebSocket.onmessage](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-onmessage) | A handler for `message` events. |
39+
| [WebSocket.onerror](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-onerror) | A handler for `error` events. |
40+
| [WebSocket.onopen](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-onopen) | A handler for `open` events. |
41+
| [WebSocket.onclose](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-onclose) | A handler for `close` events. |
42+
| [WebSocket.onping](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-onping) | A handler for `ping` events. |
43+
| [WebSocket.onpong](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-onpong) | A handler for `pong` events. |
4444

4545
<!-- vale on -->
4646

@@ -75,7 +75,7 @@ export default function () {
7575
function startWSWorker(id) {
7676
// create a new websocket connection
7777
const ws = new WebSocket(`wss://test-api.k6.io/ws/crocochat/${chatRoomName}/`);
78-
ws.binaryType = "arraybuffer";
78+
ws.binaryType = 'arraybuffer';
7979

8080
ws.addEventListener('open', () => {
8181
// change the user name

docs/sources/next/javascript-api/k6-experimental/websockets/websocket/websocket-send.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
---
22
title: 'WebSocket.send(data)'
3-
description: 'Send a data string through the connection.'
3+
description: 'Send data through the connection.'
44
weight: 10
55
---
66

77
# WebSocket.send(data)
88

9-
Send a data string through the connection.
9+
Send data through the connection.
1010
You can use `JSON.stringify` to convert a JSON or JavaScript values to a JSON string.
1111

12-
| Parameter | Type | Description |
13-
| --------- | -------------------- | ----------------- |
14-
| data | string / ArrayBuffer | The data to send. |
12+
| Parameter | Type | Description |
13+
| --------- | --------------------------------------------- | ----------------- |
14+
| data | string / ArrayBuffer / Blob / ArrayBufferView | The data to send. |
1515

1616
### Example
1717

0 commit comments

Comments
 (0)