Skip to content

Commit

Permalink
fixup! Implement ExposedThing functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Jul 9, 2024
1 parent a748279 commit 81b23e6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
35 changes: 23 additions & 12 deletions lib/src/core/implementation/exposed_thing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -288,27 +288,38 @@ class ExposedThing implements scripting_api.ExposedThing, ExposableThing {
}

@override
Future<void> handleReadAllProperties(
List<String> propertyNames,
PropertyContentMap inputs, {
Future<PropertyContentMap> handleReadAllProperties({
int? formIndex,
Map<String, Object>? uriVariables,
Object? data,
}) {
// TODO: implement handleReadAllProperties
throw UnimplementedError();
}
}) async =>
handleReadMultipleProperties(
thingDescription.properties?.keys.toList() ?? [],
);

@override
Future<PropertyContentMap> handleReadMultipleProperties(
List<String> propertyNames,
Content input, {
List<String> propertyNames, {
int? formIndex,
Map<String, Object>? uriVariables,
Object? data,
}) {
// TODO: implement handleReadMultipleProperties
throw UnimplementedError();
}) async {
final contentMapEntries = await Future.wait(
propertyNames.map(
(propertyName) async {
final content = await handleReadProperty(
propertyName,
formIndex: formIndex,
uriVariables: uriVariables,
data: data,
);

return MapEntry(propertyName, content);
},
),
);

return Map.fromEntries(contentMapEntries);
}

@override
Expand Down
7 changes: 2 additions & 5 deletions lib/src/core/protocol_interfaces/exposable_thing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,14 @@ abstract interface class ExposableThing {

/// Handles a `readmultipleproperties` operation triggered by a TD consumer.
Future<PropertyContentMap> handleReadMultipleProperties(
List<String> propertyNames,
Content input, {
List<String> propertyNames, {
int? formIndex,
Map<String, Object>? uriVariables,
Object? data,
});

/// Handles a `readallproperties` operation triggered by a TD consumer.
Future<void> handleReadAllProperties(
List<String> propertyNames,
PropertyContentMap inputs, {
Future<PropertyContentMap> handleReadAllProperties({
int? formIndex,
Map<String, Object>? uriVariables,
Object? data,
Expand Down

0 comments on commit 81b23e6

Please sign in to comment.