Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Side by Side Diff: pkg/mdns/lib/src/lookup_resolver.dart

Issue 1407123010: Extend the mDNS package with a native extension used on Mac OS (Closed) Base URL: git@github.com:dart-lang/fletch.git@master
Patch Set: Uploaded binary for Linux and added README Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698