deliver method
Implementation
Future<void> deliver(HttpRequest request) async {
final content =
utf8.decode(await request.fold(<int>[], (List<int> a, List<int> b) {
return a..addAll(b);
}));
await request.response.close();
final doc = XmlDocument.parse(content);
final props = doc.rootElement.children.whereType<XmlElement>().toList();
final map = <String, dynamic>{};
for (XmlElement prop in props) {
if (prop.children.isEmpty) {
continue;
}
final XmlElement child =
prop.children.firstWhere((x) => x is XmlElement) as XmlElement;
final String p = child.name.local;
if (lastStateVariable != null && lastStateVariable!.name == p) {
final value = XmlUtils.asRichValue(child.innerText);
_controller!.add(value);
_lastValue = value;
return;
} else if (lastStateVariable == null) {
map[p] = XmlUtils.asRichValue(child.innerText);
}
}
if (lastStateVariable == null && map.isNotEmpty) {
_controller!.add(map);
_lastValue = map;
}
}