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

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

Issue 1430433005: Minor fixes to the mDNS package (Closed) Base URL: git@github.com:dart-lang/fletch.git@master
Patch Set: 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
« no previous file with comments | « pkg/mdns/lib/mdns.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Fletch 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.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 library mdns.src.native_protocol_client; 5 library mdns.src.native_protocol_client;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:io'; 9 import 'dart:io';
10 10
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 125
126 Stream<ResourceRecord> lookup( 126 Stream<ResourceRecord> lookup(
127 int type, 127 int type,
128 String name, 128 String name,
129 {Duration timeout: const Duration(seconds: 5)}) { 129 {Duration timeout: const Duration(seconds: 5)}) {
130 if (!_started) { 130 if (!_started) {
131 throw new StateError('mDNS client is not started'); 131 throw new StateError('mDNS client is not started');
132 } 132 }
133 133
134 // Look for entries in the cache. 134 // Look for entries in the cache.
135 List<ResourceRecordCache> cached = <ResourceRecord>[]; 135 List<ResourceRecord> cached = <ResourceRecord>[];
136 cache.lookup(name, type, cached); 136 cache.lookup(name, type, cached);
137 if (cached.isNotEmpty) { 137 if (cached.isNotEmpty) {
138 StreamController controller = new StreamController(); 138 StreamController controller = new StreamController();
139 cached.forEach(controller.add); 139 cached.forEach(controller.add);
140 controller.close(); 140 controller.close();
141 return controller.stream; 141 return controller.stream;
142 } 142 }
143 143
144 // Add the pending request before sending the query. 144 // Add the pending request before sending the query.
145 var results = _resolver.addPendingRequest(type, name, timeout); 145 var results = _resolver.addPendingRequest(type, name, timeout);
(...skipping 12 matching lines...) Expand all
158 if (event == RawSocketEvent.READ) { 158 if (event == RawSocketEvent.READ) {
159 Datagram datagram = _incoming.receive(); 159 Datagram datagram = _incoming.receive();
160 List<ResourceRecord> response = decodeMDnsResponse(datagram.data); 160 List<ResourceRecord> response = decodeMDnsResponse(datagram.data);
161 if (response != null) { 161 if (response != null) {
162 cache.updateRecords(response); 162 cache.updateRecords(response);
163 _resolver.handleResponse(response); 163 _resolver.handleResponse(response);
164 } 164 }
165 } 165 }
166 } 166 }
167 } 167 }
OLDNEW
« no previous file with comments | « pkg/mdns/lib/mdns.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698