my.sendSocketMessage
Use this API to send data over WebSocket connection. Call my.connectSocket first and send data after the my.onSocketOpen callback.
Sample Code
copy
my.sendSocketMessage({
data: this.data.toSendMessage, // The data to be sent
success: (res) => {
my.alert({content: 'The data sent!' + this.data.toSendMessage});
},
});Note:The case is only for reference. Please use your own URL to test.
Parameters
| Property | Type | Required | Description |
| data | String | Yes | The data to be sent, in text string or base64 encoded string. |
| isBuffer | Boolean | No | 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. |
| success | Function | No | The callback function for a successful API call. |
| fail | Function | No | The callback function for a failed API call. |
| complete | Function | No | The callback function used when the API call is completed. This function is always executed no matter the call succeeds or fails. |