connect method
Implementation
Future<void> connect() async {
if (communicator == null) {
throw StateError("set communicator before calling connect()");
}
communicator!.onConnected = _onConnected;
communicator!.onDisconnected = _onDisconnected;
communicator!.onAutoReconnect = _onAutoReconnect;
communicator!.onAutoReconnected = _onAutoReconnected;
try {
await communicator!.connect();
} on ConnectError {
_emit(FarmEventType.farmConnectError);
}
_communicatorSubscription = communicator!.messages.listen((message) {
// _log.info("msg on ${message.topic}");
processMessage(message);
});
}