snap_sendWebSocketMessage
Description
Send a message to an open WebSocket connection. The message will be sent to
the WebSocket connection with the specified ID, which must have been
previously opened by the Snap using the snap_openWebSocket
method.
Parameters
object
requiredAn object describing the WebSocket message to send.
id
stringThe ID of the WebSocket connection to send a message to.
message
unionThe message to send. This can be either a string or an array of numbers representing binary data.
Options
string
or
number[]
Returns
null
This method does not return any data, so the result is always null.
Example
- Manifest
- Usage
{
"initialPermissions": {
"endowment:network-access": {}
}
}
await wallet.request({
method: "snap_sendWebSocketMessage",
params: {
id: "websocket-connection-id",
message: "Hello, WebSocket!", // or message: [1, 2, 3] for binary data
},
});