respondToSearch method
Implementation
Future<List<String>> respondToSearch(String? target, Datagram pkt, Map<String, String> headers) async {
var out = <String>[];
addDevice(String? profile) {
var buff = StringBuffer();
buff.write("HTTP/1.1 200 OK\r\n");
buff.write("CACHE-CONTROL: max-age=180\r\n");
buff.write("EXT:\r\n");
buff.write("LOCATION: ${rootDescriptionUrl}\r\n");
buff.write("SERVER: UPnP.dart/1.0\r\n");
buff.write("ST: ${profile}\r\n");
buff.write("USN: ${device.deviceType}::${profile}\r\n");
out.add(buff.toString());
}
if (target == "ssdp:all") {
addDevice(device.deviceType);
for (UpnpHostService svc in device.services) {
addDevice(svc.type);
}
} else if (target == device.deviceType || target == "upnp:rootdevice") {
addDevice(device.deviceType);
} else if (target == device.udn) {
addDevice(device.deviceType);
}
var svc = device.findService(target);
if (svc != null) {
addDevice(svc.type);
}
return out;
}