Skip to main content
  • Snap

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

The request parameters for the snap_sendWebSocketMessage method.

id

string
required

The ID of the WebSocket connection to send a message to.

message

union
required

The message to send.

Options

string

or

array
number

Returns

null

The result returned by the snap_sendWebSocketMessage method.

Example

await wallet.request({
method: "snap_sendWebSocketMessage",
params: {
id: "websocket-connection-id",
message: "Hello, WebSocket!", // or message: [1, 2, 3] for binary data
},
});