discoverRDServices method
Implementation
@override
Future<List<RdServiceModel>> discoverRDServices() async {
List<RdServiceModel> avdmList = [];
//Scan port from 11100 to 11120
pluginDebug("\nScanning AVDM from port 11100 to 11120, this will take few Seconds",
usePrint: true);
for (var i = 11100; i <= 11120; i++) {
final client =
await httpClient.openUrl("RDSERVICE", Uri.parse("http://127.0.0.1:$i"));
client.headers.set("Content-Type", "text/xml; charset=utf-8");
client.headers.set("Accept", "text/xml");
try {
String dataStr =
xmlStrToJsonStr(await (await client.close()).transform(utf8.decoder).join());
RdServiceModel rd = RdServiceModel.fromMap(json.decode(dataStr), port: i);
if (kDebugMode && (rd.rdStatus != null || rd.rdInfo != null)) {
pluginDebug("Status =>${rd.rdStatus.toString()} Info => ${rd.rdInfo ?? ""}");
}
avdmList.add(rd);
} catch (e) {
pluginDebug(
"--- Error on discoverAVDM ---port:$i",
);
}
}
return avdmList;
}