File tree Expand file tree Collapse file tree 2 files changed +46
-2
lines changed Expand file tree Collapse file tree 2 files changed +46
-2
lines changed Original file line number Diff line number Diff line change 88
99import "package:dart_wot/binding_ndn.dart" ;
1010import "package:dart_wot/core.dart" ;
11+ import "package:dart_wot/src/binding_ndn/ndn_config.dart" ;
1112
1213Future <void > main () async {
13- final servient = Servient (clientFactories: [NdnClientFactory (ndnConfig)]);
14+ final faceUri = Uri .parse ("tcp4://localhost:6363" );
15+ final ndnConfig = NdnConfig (
16+ faceUri: faceUri,
17+ );
18+
19+ final servient = Servient (
20+ clientFactories: [NdnClientFactory (ndnConfig: ndnConfig)],
21+ );
22+
23+ final wot = await servient.start ();
24+
25+ final thingDescription = {
26+ "@context" : "https://www.w3.org/2022/wot/td/v1.1" ,
27+ "title" : "NDN Thing" ,
28+ "id" : "urn:test" ,
29+ "securityDefinitions" : {
30+ "nosec_sc" : {"scheme" : "nosec" },
31+ },
32+ "security" : "nosec_sc" ,
33+ "properties" : {
34+ "ping" : {
35+ "forms" : [
36+ {
37+ "contentType" : "text/plain" ,
38+ "href" : "ndn:///ndn/ping/9001" ,
39+ },
40+ ],
41+ },
42+ },
43+ }.toThingDescription ();
44+
45+ final consumedThing = await wot.consume (thingDescription);
46+
47+ final result = await consumedThing.readProperty ("ping" );
48+
49+ print (await result.value ());
50+
51+ await servient.shutdown ();
1452}
Original file line number Diff line number Diff line change 44//
55// SPDX-License-Identifier: BSD-3-Clause
66
7+ import "package:meta/meta.dart" ;
8+
79import "../../core.dart" ;
810import "ndn_config.dart" ;
911import "ndn_consumer.dart" ;
1012
1113/// A [ProtocolClientFactory] that produces
14+ @immutable
1215class NdnClientFactory implements ProtocolClientFactory {
13- NdnClientFactory (this .ndnConfig);
16+ /// Creates a new [ProtocolClientFactory] from an [ndnConfig] .
17+ const NdnClientFactory ({
18+ this .ndnConfig = const NdnConfig (),
19+ });
1420
1521 /// The [NdnConfig] acting as the blueprint for creating
1622 final NdnConfig ndnConfig;
You can’t perform that action at this time.
0 commit comments