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( |
Søren Gjesse
2015/11/06 08:44:48
This should be a Stream of ResourceRecord now.
karlklose
2015/11/06 12:20:00
Done.
|
- 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); |
_resolver.handleResponse([response]); |
} else { |
// TODO(sgjesse): Improve the error handling. |