[frdp] Ignore stale ports. (#16944)

When forwarding all ports, run a test connection to each Dart VM instance, stopping port forwarding if the connection fails.

Also does the same for any batched calls that hit all Dart VM instances.
This commit is contained in:
Andrew Davies
2018-04-27 13:24:01 -07:00
committed by GitHub
parent 549acac655
commit 61de5014b6
4 changed files with 72 additions and 23 deletions

View File

@@ -30,9 +30,9 @@ void main() {
const String address = 'fe80::8eae:4cff:fef4:9247';
const String interface = 'eno1';
// Adds some extra junk to make sure the strings will be cleaned up.
when(mockRunner.run(typed(any)))
.thenAnswer((_) => new Future<List<String>>.value(
<String>['123\n\n\n', '456 ', '789']));
when(mockRunner.run(typed(any))).thenAnswer((_) =>
new Future<List<String>>.value(
<String>['123\n\n\n', '456 ', '789']));
when(mockRunner.address).thenReturn(address);
when(mockRunner.interface).thenReturn(interface);
int port = 0;
@@ -100,8 +100,10 @@ void main() {
mockPeerConnections.add(mp);
uriConnections.add(uri);
when(mp.sendRequest(typed<String>(any), typed<String>(any)))
// The local ports match the desired indices for now, so get the
// canned response from the URI port.
.thenAnswer((_) => new Future<Map<String, dynamic>>(
() => flutterViewCannedResponses[flutterViewIndex++]));
() => flutterViewCannedResponses[uri.port]));
return mp;
});
}