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

Unified Diff: pkg/mdns/lib/src/native_extension_client.dart

Issue 1412063015: Improve resource record implementation in the mdns package. (Closed) Base URL: https://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 side-by-side diff with in-line comments
Download patch
Index: pkg/mdns/lib/src/native_extension_client.dart
diff --git a/pkg/mdns/lib/src/native_extension_client.dart b/pkg/mdns/lib/src/native_extension_client.dart
index 97148af8f2534f2ef74955d12d2c5f14711cc5ce..b26ad61256d797beb77abee23c4eae094922c6e1 100644
--- a/pkg/mdns/lib/src/native_extension_client.dart
+++ b/pkg/mdns/lib/src/native_extension_client.dart
@@ -13,6 +13,7 @@ import 'package:mdns/src/lookup_resolver.dart';
import 'package:mdns/src/native_extension_api.dart'
deferred as native_extension_api;
import 'package:mdns/src/packet.dart';
+import 'package:mdns/src/constants.dart';
// Requests Ids. This should be aligned with the C code.
enum RequestType {
@@ -56,25 +57,32 @@ class NativeExtensionMDnsClient implements MDnsClient {
}
Future<InternetAddress> lookup(
- String hostname, {Duration timeout: const Duration(seconds: 5)}) {
+ int type,
+ String name,
+ {Duration timeout: const Duration(seconds: 5)}) {
if (!_started) {
throw new StateError('mDNS client is not started');
}
+ if (type != RRType.A) {
+ // TODO(karlklose): add support.
+ throw 'RR type $type not supported.';
+ }
+
// Add the pending request before sending the query.
- var future = _resolver.addPendingRequest(hostname, timeout);
+ var future = _resolver.addPendingRequest(type, name, timeout);
// Send the request.
_service.send([_incoming.sendPort,
RequestType.lookupRequest.index,
- hostname]);
+ name]);
return future;
}
// Process incoming responses.
_handleIncoming(response) {
- // Right not the only response we can get is the response to a
+ // Right now the only response we can get is the response to a
// lookupRequest where the response looks like this:
//
// response[0]: hostname (String)
@@ -82,8 +90,11 @@ class NativeExtensionMDnsClient implements MDnsClient {
if (response is List && response.length == 2) {
if (response[0] is String &&
response[1] is List && response[1].length == 4) {
- response = new DecodeResult(response[0],
- new InternetAddress(response[1].join('.')));
+ response = new ResourceRecord(
+ RRType.A,
+ response[0],
+ response[1].codeUnits,
+ new DateTime.now().millisecondsSinceEpoch + 2000);
Søren Gjesse 2015/11/06 08:44:48 Please add a comment on the 2s constant here.
karlklose 2015/11/06 12:19:59 Done.
_resolver.handleResponse([response]);
} else {
// TODO(sgjesse): Improve the error handling.

Powered by Google App Engine
This is Rietveld 408576698