WebSocketService Actions
4 actions registered.
| Name | Deprecated |
|---|---|
close | |
getAll | |
open | |
sendMessage |
WebSocketService:close
Package: @metamask/snaps-controllers
Close a given WebSocket connection.
Parameters:
| Name | Description |
|---|---|
snapId | The Snap ID. |
id | The identifier for the WebSocket connection. |
Handler signature:
(snapId: SnapId, id: string) => void
WebSocketService:getAll
Package: @metamask/snaps-controllers
Get a list of all open WebSocket connections for a Snap ID.
Parameters:
| Name | Description |
|---|---|
snapId | The Snap ID. |
Returns: A list of WebSocket connections.
Handler signature:
(snapId: SnapId) => {
id: string;
url: string;
protocols: string[];
}[]
WebSocketService:open
Package: @metamask/snaps-controllers
Open a WebSocket connection.
Parameters:
| Name | Description |
|---|---|
snapId | The Snap ID. |
url | The URL for the WebSocket connection. |
protocols | An optional parameter for protocols. |
Returns: The identifier for the opened connection.
Handler signature:
(snapId: SnapId, url: string, protocols?: string[]) => Promise<string>
WebSocketService:sendMessage
Package: @metamask/snaps-controllers
Send a message from a given Snap ID to a WebSocket connection.
Parameters:
| Name | Description |
|---|---|
snapId | The Snap ID. |
id | The identifier for the WebSocket connection. |
data | The message to send. |
Handler signature:
(snapId: SnapId, id: string, data: string | number[]) => Promise<void>