bind method
Implementation
Future<bool> bind() async {
final _ip = (await tryCatch(() => intranetIpv4()))?.address;
if (_ip != ip) {
ip = _ip;
this.soap = null;
upnpFalse();
}
final soapIsNull = this.soap == null;
this.soap ??= await findSoap();
if (this.soap == null) {
if (!soapIsNull) {
upnpFalse();
}
return false;
}
final soap = this.soap!;
/*
for (var i in await soap.ls()) {
final protocol = i[4];
final externalPort = i[0];
print("> ${i[3]} $protocol $ip $externalPort");
}
// */
if (ip != null) {
for (var i in Protocol.values) {
final protocol = i.index;
final protocolMap = map[protocol];
late final bool state;
for (var portState in protocolMap.entries) {
if (await soap.add(i, ip!, portState.key,
description: description, duration: duration + 60)) {
state = true;
} else {
state = false;
}
if (portState.value != state) {
protocolMap[portState.key] = state;
callback(i, portState.key, state);
}
}
}
return true;
}
return false;
}