Skip to content

Commit

Permalink
chore: add simple example for TDD discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Dec 6, 2024
1 parent 49c754f commit d3e6b08
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions example/tdd_discovery.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2024 Contributors to the Eclipse Foundation. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// SPDX-License-Identifier: BSD-3-Clause

// ignore_for_file: avoid_print

import "package:dart_wot/binding_http.dart";
import "package:dart_wot/core.dart";

Future<void> main() async {
final servient = Servient.create(
clientFactories: [
HttpClientFactory(),
],
);
final wot = await servient.start();

final url = Uri.parse("http://plugfest.thingweb.io:8081");
print("Requesting TD from $url ...");
final thingDiscoveryProcess = await wot.exploreDirectory(url);

thingDiscoveryProcess.listen(
(thingDescription) => print(thingDescription.title),
onError: print,
);

await servient.shutdown();
}

0 comments on commit d3e6b08

Please sign in to comment.