connect method
void
connect()
Implementation
void connect() async {
try {
_logger.i('TxSocket :: connect : $hostAddress');
_socket = await WebSocket.connect(hostAddress);
_socket
..pingInterval = const Duration(seconds: 10)
..timeout(const Duration(seconds: 30));
onOpen.call();
_socket.listen(
(dynamic data) {
onMessage.call(data);
},
onDone: () {
onClose.call(
_socket.closeCode ?? 0,
_socket.closeReason ?? 'Closed for unknown reason',
);
},
);
} catch (e) {
onClose.call(500, e.toString());
}
}