| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 library mdns.src.lookup_resolver; | 5 library mdns.src.lookup_resolver; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'package:mdns/src/packet.dart'; | 10 import 'package:mdns/src/packet.dart'; |
| 11 | 11 |
| 12 class PendingRequest extends LinkedListEntry { | 12 class PendingRequest extends LinkedListEntry { |
| 13 final String hostname; | 13 final String hostname; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 27 var request = new PendingRequest(hostname, completer); | 27 var request = new PendingRequest(hostname, completer); |
| 28 pendingRequests.add(request); | 28 pendingRequests.add(request); |
| 29 return completer.future.timeout(timeout, onTimeout: () { | 29 return completer.future.timeout(timeout, onTimeout: () { |
| 30 request.unlink(); | 30 request.unlink(); |
| 31 return null; | 31 return null; |
| 32 }); | 32 }); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void handleResponse(List<DecodeResult> response) { | 35 void handleResponse(List<DecodeResult> response) { |
| 36 for (var r in response) { | 36 for (var r in response) { |
| 37 var name = r.name.toLowerCase(); |
| 38 if (name.endsWith('.')) name = name.substring(0, name.length - 1); |
| 37 pendingRequests | 39 pendingRequests |
| 38 .where((pendingRequest) => pendingRequest.hostname == r.name) | 40 .where((pendingRequest) { |
| 41 return pendingRequest.hostname.toLowerCase() == name; |
| 42 }) |
| 39 .forEach((pendingRequest) { | 43 .forEach((pendingRequest) { |
| 40 pendingRequest.completer.complete(r.address); | 44 pendingRequest.completer.complete(r.address); |
| 41 pendingRequest.unlink(); | 45 pendingRequest.unlink(); |
| 42 }); | 46 }); |
| 43 } | 47 } |
| 44 } | 48 } |
| 45 } | 49 } |
| 46 | |
| OLD | NEW |