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 8
8
9
9
import "package:dart_wot/binding_ndn.dart" ;
10
10
import "package:dart_wot/core.dart" ;
11
+ import "package:dart_wot/src/binding_ndn/ndn_config.dart" ;
11
12
12
13
Future <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 ();
14
52
}
Original file line number Diff line number Diff line change 4
4
//
5
5
// SPDX-License-Identifier: BSD-3-Clause
6
6
7
+ import "package:meta/meta.dart" ;
8
+
7
9
import "../../core.dart" ;
8
10
import "ndn_config.dart" ;
9
11
import "ndn_consumer.dart" ;
10
12
11
13
/// A [ProtocolClientFactory] that produces
14
+ @immutable
12
15
class NdnClientFactory implements ProtocolClientFactory {
13
- NdnClientFactory (this .ndnConfig);
16
+ /// Creates a new [ProtocolClientFactory] from an [ndnConfig] .
17
+ const NdnClientFactory ({
18
+ this .ndnConfig = const NdnConfig (),
19
+ });
14
20
15
21
/// The [NdnConfig] acting as the blueprint for creating
16
22
final NdnConfig ndnConfig;
You can’t perform that action at this time.
0 commit comments