execute method
Implementation
@override
Future<bool?> execute(
String caller, String propertyOrFunction, List<dynamic> arguments) async {
var function = propertyOrFunction.toLowerCase().trim();
switch (function) {
case "write":
case "publish":
String? topic = toStr(elementAt(arguments, 0));
String? message = toStr(elementAt(arguments, 1));
if (mqtt != null && topic != null && message != null) {
mqtt!.publish(topic, message);
}
return true;
case "read":
case "subscribe":
String? topic = toStr(elementAt(arguments, 0));
if (!isNullOrEmpty(topic)) mqtt?.subscribe(topic!);
return true;
case "unsubscribe":
String? topic = toStr(elementAt(arguments, 0));
if (mqtt != null && topic != null) mqtt!.unsubscribe(topic);
return true;
case "connect":
return await start();
case "disconnect":
return await stop();
}
return super.execute(caller, propertyOrFunction, arguments);
}