sendMessage function
Send Message with defined web socket
Implementation
void sendMessage(WebSocket? webSocket, SocketData socketData,
{Function? onError}) {
try {
if (webSocket != null && webSocket.closeCode == null) {
// print("SEND MESSAGE IN : ${socketData.fullData}");
webSocket.addUtf8Text(utf8.encode(json.encode(socketData.toJson())));
} else {
if (onError != null) onError();
// print("SEND AND WAIT MESSAGE IN CLOSED: ${socketData.fullData}");
}
} on Exception {
if (onError != null) onError();
//TODO:ADD ERROR ANALYSIS
}
}