parseCandidate method
dynamic
parseCandidate(
- String line
)
Implementation
parseCandidate(String line) {
List<String> parts;
// Parse both variants.
if (line.indexOf('a=candidate:') == 0) {
parts = line.substring(12).split(' ');
} else {
parts = line.substring(10).split(' ');
}
final candidate = {
"foundation": parts[0],
"component": parts[1],
"protocol": parts[2].toLowerCase(),
"priority": int.parse(parts[3], radix: 10),
"ip": parts[4],
"port": int.parse(parts[5], radix: 10),
// skip parts[6] == 'typ'
"type": parts[7]
};
for (var i = 8; i < parts.length; i += 2) {
switch (parts[i]) {
case 'raddr':
candidate["relatedAddress"] = parts[i + 1];
break;
case 'rport':
candidate["relatedPort"] = int.parse(parts[i + 1], radix: 10);
break;
case 'tcptype':
candidate["tcpType"] = parts[i + 1];
break;
default: // Unknown extensions are silently ignored.
break;
}
}
return candidate;
}