my.onSocketMessage
Use this API to listen to the event of receiving server messages by WebSocket.
Callback Return Value
| 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. |
Sample Code
copy
my.connectSocket({
url: 'Server URL'
})
my.onSocketMessage(function(res) {
console.log('Server content received:' + res.data)
})Note: The case is only for reference. Please use your own URL to test.