@@ -288,84 +288,126 @@ class ExposedThing implements scripting_api.ExposedThing, ExposableThing {
288288 }
289289
290290 @override
291- Stream <Content > handleObserveProperty (
292- String propertyName, {
291+ Future <void > handleReadAllProperties (
292+ List <String > propertyNames,
293+ PropertyContentMap inputs, {
293294 int ? formIndex,
294295 Map <String , Object >? uriVariables,
295296 Object ? data,
296297 }) {
297- final property = _obtainProperty (propertyName);
298-
299- // TODO: implement handleObserveProperty
298+ // TODO: implement handleReadAllProperties
300299 throw UnimplementedError ();
301300 }
302301
303302 @override
304- Future <void > handleReadAllProperties (
303+ Future <PropertyContentMap > handleReadMultipleProperties (
305304 List <String > propertyNames,
306- PropertyContentMap inputs , {
305+ Content input , {
307306 int ? formIndex,
308307 Map <String , Object >? uriVariables,
309308 Object ? data,
310309 }) {
311- // TODO: implement handleReadAllProperties
310+ // TODO: implement handleReadMultipleProperties
312311 throw UnimplementedError ();
313312 }
314313
315314 @override
316- Future <PropertyContentMap > handleReadMultipleProperties (
315+ Future <void > handleWriteMultipleProperties (
317316 List <String > propertyNames,
318317 Content input, {
319318 int ? formIndex,
320319 Map <String , Object >? uriVariables,
321320 Object ? data,
322321 }) {
323- // TODO: implement handleReadMultipleProperties
322+ // TODO: implement handleWriteMultipleProperties
324323 throw UnimplementedError ();
325324 }
326325
327326 @override
328- Stream < Content > handleSubscribeEvent (
329- String eventName , {
327+ Future < void > handleObserveProperty (
328+ String propertyName , {
330329 int ? formIndex,
331330 Map <String , Object >? uriVariables,
332331 Object ? data,
333- }) {
334- // TODO: implement handleSubscribeEvent
335- throw UnimplementedError ();
332+ }) async {
333+ final observeHandler = _propertyObserveHandlers[propertyName];
334+
335+ if (observeHandler == null ) {
336+ throw Exception (
337+ "Observe handler for property $propertyName is not defined." ,
338+ );
339+ }
340+
341+ await observeHandler (
342+ data: data,
343+ uriVariables: uriVariables,
344+ formIndex: formIndex,
345+ );
336346 }
337347
338348 @override
339- Future <void > handleUnsubscribeEvent (
340- String eventName , {
349+ Future <void > handleUnobserveProperty (
350+ String propertyName , {
341351 int ? formIndex,
342352 Map <String , Object >? uriVariables,
343353 Object ? data,
344- }) {
345- // TODO: implement handleUnsubscribeEvent
346- throw UnimplementedError ();
354+ }) async {
355+ final unobserveHandler = _propertyUnobserveHandlers[propertyName];
356+
357+ if (unobserveHandler == null ) {
358+ throw Exception (
359+ "Unobserve handler for property $propertyName is not defined." ,
360+ );
361+ }
362+
363+ await unobserveHandler (
364+ data: data,
365+ uriVariables: uriVariables,
366+ formIndex: formIndex,
367+ );
347368 }
348369
349370 @override
350- Future <void > handleWriteMultipleProperties (
351- List <String > propertyNames,
352- Content input, {
371+ Future <void > handleSubscribeEvent (
372+ String eventName, {
353373 int ? formIndex,
354374 Map <String , Object >? uriVariables,
355375 Object ? data,
356- }) {
357- // TODO: implement handleWriteMultipleProperties
358- throw UnimplementedError ();
376+ }) async {
377+ final subscribeHandler = _eventSubscribeHandlers[eventName];
378+
379+ if (subscribeHandler == null ) {
380+ throw Exception (
381+ "Observe handler for property $eventName is not defined." ,
382+ );
383+ }
384+
385+ await subscribeHandler (
386+ data: data,
387+ uriVariables: uriVariables,
388+ formIndex: formIndex,
389+ );
359390 }
360391
361392 @override
362- Future <void > handleUnobserveProperty (
393+ Future <void > handleUnsubscribeEvent (
363394 String eventName, {
364395 int ? formIndex,
365396 Map <String , Object >? uriVariables,
366397 Object ? data,
367- }) {
368- // TODO: implement handleUnobserveProperty
369- throw UnimplementedError ();
398+ }) async {
399+ final unsubscribeHandler = _eventUnsubscribeHandlers[eventName];
400+
401+ if (unsubscribeHandler == null ) {
402+ throw Exception (
403+ "Observe handler for property $eventName is not defined." ,
404+ );
405+ }
406+
407+ await unsubscribeHandler (
408+ data: data,
409+ uriVariables: uriVariables,
410+ formIndex: formIndex,
411+ );
370412 }
371413}
0 commit comments