onMessage method
Implementation
Future<void> onMessage(String message) async {
if (_disposed) return;
final pkt = _SsdpPacket.parse(message);
if (pkt == null) return;
final loc = pkt.location;
if (pkt.isByebye) {
_removeByLocation(loc);
return;
}
if (loc.isEmpty) return;
final known = _locationKeys[loc];
final cached = known == null ? null : deviceList[known];
if (cached != null) {
cached.updateActive(DateTime.now());
_emit(false);
return;
}
if (!_inflight.add(loc)) return;
try {
final info = await _fetchInfo(loc);
if (info == null || _disposed) return;
_locationKeys[loc] = info.URLBase;
final existed = deviceList.containsKey(info.URLBase);
deviceList
.putIfAbsent(info.URLBase, () => DLNADevice(info))
.updateActive(DateTime.now());
_emit(!existed);
} finally {
_inflight.remove(loc);
}
}