@@ -46,8 +46,8 @@ Below you can find a basic example for incrementing and reading the value of a
4646counter Thing, which is part of the
4747[ Thingweb Online Things] ( https://www.thingweb.io/services ) .
4848
49- In the example, we first create a WoT runtime using a ` Servient ` with CoAP
50- support.
49+ In the example, we first create a WoT runtime using a ` Servient ` with CoAP and
50+ HTTP support.
5151With the runtime, we then retrieve a TD (using the ` requestThingDescription() `
5252method) and consume it (using the ` consume() ` method), creating a
5353` ConsumedThing ` object,
@@ -56,12 +56,14 @@ Afterward, the actual interactions with the counter are performed by calling the
5656
5757``` dart
5858import "package:dart_wot/binding_coap.dart";
59+ import "package:dart_wot/binding_http.dart";
5960import "package:dart_wot/core.dart";
6061
6162Future<void> main(List<String> args) async {
6263 final servient = Servient(
6364 clientFactories: [
6465 CoapClientFactory(),
66+ HttpClientFactory(),
6567 ],
6668 );
6769 final wot = await servient.start();
@@ -76,12 +78,17 @@ Future<void> main(List<String> args) async {
7678 '"${thingDescription.title}"!',
7779 );
7880
81+ print(consumedThing.thingDescription.events);
82+ final subscription = await consumedThing.subscribeEvent("change", print);
83+
7984 print("Incrementing counter ...");
8085 await consumedThing.invokeAction("increment");
8186
8287 final status = await consumedThing.readProperty("count");
8388 final value = await status.value();
8489 print("New counter value: $value");
90+
91+ await subscription.stop();
8592}
8693```
8794
0 commit comments