Skip to content

Commit

Permalink
Merge branch 'main' into timerChanges
Browse files Browse the repository at this point in the history
  • Loading branch information
heitortsergent authored Sep 20, 2024
2 parents ac44bb5 + dd93b3a commit dd1ccea
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,26 @@ The `WebSocket API` is not fully implemented, and we're working on it, but we be
| [WebSocket(url, protocols, params)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket) | Constructs a new WebSocket connection. |
| [WebSocket.close()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-close) | Close the WebSocket connection. |
| [WebSocket.ping()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-ping) | Send a ping. |
| [WebSocket.send(data)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-send) | Send string data. |
| [WebSocket.send(data)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-send) | Send data. |
| [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. |
| [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). |

A WebSocket instance also has the following properties:

<!-- vale off -->

| Class/Property | Description |
| --------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 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). |
| WebSocket.url | The URL of the connection as resolved by the constructor. |
| WebSocket.bufferedAmount | The number of bytes of data that have been queued using calls to `send()` but not yet transmitted to the network. |
| 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"`. |
| [WebSocket.onmessage](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-onmessage) | A handler for `message` events. |
| [WebSocket.onerror](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-onerror) | A handler for `error` events. |
| [WebSocket.onopen](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-onopen) | A handler for `open` events. |
| [WebSocket.onclose](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-onclose) | A handler for `close` events. |
| [WebSocket.onping](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-onping) | A handler for `ping` events. |
| [WebSocket.onpong](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-onpong) | A handler for `pong` events. |
| Class/Property | Description |
| --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| 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). |
| WebSocket.url | The URL of the connection as resolved by the constructor. |
| WebSocket.bufferedAmount | The number of bytes of data that have been queued using calls to `send()` but not yet transmitted to the network. |
| 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"`. |
| [WebSocket.onmessage](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-onmessage) | A handler for `message` events. |
| [WebSocket.onerror](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-onerror) | A handler for `error` events. |
| [WebSocket.onopen](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-onopen) | A handler for `open` events. |
| [WebSocket.onclose](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-onclose) | A handler for `close` events. |
| [WebSocket.onping](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-onping) | A handler for `ping` events. |
| [WebSocket.onpong](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/websockets/websocket/websocket-onpong) | A handler for `pong` events. |

<!-- vale on -->

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
title: 'WebSocket.send(data)'
description: 'Send a data string through the connection.'
description: 'Send data through the connection.'
weight: 10
---

# WebSocket.send(data)

Send a data string through the connection.
Send data through the connection.
You can use `JSON.stringify` to convert a JSON or JavaScript values to a JSON string.

| Parameter | Type | Description |
| --------- | -------------------- | ----------------- |
| data | string / ArrayBuffer | The data to send. |
| Parameter | Type | Description |
| --------- | --------------------------------------------- | ----------------- |
| data | string / ArrayBuffer / Blob / ArrayBufferView | The data to send. |

### Example

Expand Down
30 changes: 30 additions & 0 deletions src/data/doc-extensions/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,36 @@
"categories": ["Misc"],
"tiers": ["Community"],
"cloudEnabled": false
},
{
"name": "xk6-output-opentelemetry",
"description": "Export k6 results in OpenTelemetry format",
"url": "/~https://github.com/grafana/xk6-output-opentelemetry",
"logo": "",
"author": {
"name": "Grafana",
"url": "/~https://github.com/grafana"
},
"stars": "0",
"type": ["Output"],
"categories": ["Reporting", "Observability"],
"tiers": ["Official"],
"cloudEnabled": false
},
{
"name": "xk6-aws",
"description": "Alternative to the official AWS JS Lib that relies on the AWS SDK for Go to interact with Amazon Web Services",
"url": "/~https://github.com/joanlopez/xk6-aws",
"logo": "",
"author": {
"name": "Joan López de la Franca Beltran",
"url": "/~https://github.com/joanlopez"
},
"stars": "0",
"type": ["JavaScript"],
"categories": ["Misc"],
"tiers": ["Community"],
"cloudEnabled": false
}
]
}

0 comments on commit dd1ccea

Please sign in to comment.