snap_getWebSockets
Description
Get the connected WebSockets for the Snap.
Parameters
This method does not have any parameters.
Returns
object[]
An array of connected WebSockets for the Snap.
object
id
stringThe unique identifier of the WebSocket connection.
url
stringThe URL of the WebSocket connection.
protocols
string[]An array of subprotocols used in the WebSocket connection (if any).
Example
- Manifest
- Usage
{
"initialPermissions": {
"endowment:network-access": {}
}
}
const webSockets = await snap.request({ method: "snap_getWebSockets" });
console.log(webSockets);
// Example output:
// [
// {
// id: 'websocket-1',
// url: 'wss://example.com/socket',
// protocols: ['protocol1', 'protocol2'],
// },
// {
// id: 'websocket-2',
// url: 'ws://example.org/endpoint',
// protocols: [],
// },
// ]