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

id

stringrequired

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

message

number[] | stringrequired

The message to send.

Example

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