> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rebellapp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# my.onSocketMessage

> Listen for WebSocket messages.

Register a callback for incoming WebSocket messages.

## Parameters

| Property | Type     | Required | Description          |
| -------- | -------- | -------- | -------------------- |
| callback | Function | Yes      | Handler for messages |

## Callback Parameters

| Property | Type               | Description                                                                                                                                                                                   |
| -------- | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| data     | String/ArrayBuffer | Messages returned by the server, in text string or base64 encoded string                                                                                                                      |
| isBuffer | Boolean            | If the value of this field is `true`, the `data` field represents the received base64 encoded binary strings. If the value of this field is empty, the `data` field represents normal strings |

## Code Example

```javascript theme={null}
my.onSocketMessage((res) => {
  console.log('Received:', res.data);
});
```
