Skip to content

Commit 17334a9

Browse files
committed
feat(example): add example for directory discovery
1 parent df42311 commit 17334a9

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

example/directory_discovery.dart

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2024 Contributors to the Eclipse Foundation. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
//
5+
// SPDX-License-Identifier: BSD-3-Clause
6+
7+
// ignore_for_file: avoid_print
8+
9+
import "package:dart_wot/binding_http.dart";
10+
import "package:dart_wot/core.dart";
11+
12+
Future<void> main(List<String> args) async {
13+
final servient = Servient(
14+
clientFactories: [
15+
HttpClientFactory(),
16+
],
17+
);
18+
19+
final wot = await servient.start();
20+
// FIXME(JRKhb): The "things" property currently points to "localhost",
21+
// preventing this example from working
22+
final url = Uri.parse("https://zion.vaimee.com/.well-known/wot");
23+
24+
final thingDiscovery = await wot.exploreDirectory(url);
25+
26+
await for (final thingDescription in thingDiscovery) {
27+
print(thingDescription);
28+
}
29+
}

0 commit comments

Comments
 (0)