|
251 | 251 | <p>
|
252 | 252 | The following scripting use cases are covered in this specification:
|
253 | 253 | <ul>
|
254 |
| - <li>Discover <a>Thing</a>s by filters defined on <a>Thing Description</a>s for client-side access</li> |
255 |
| - <li>Discover <a>Thing</a>s by semantic filters for client-side access</li> |
256 |
| - <li><a>Consume a TD</a> of a remote <a>Thing</a>.</li> |
| 254 | + <li>Discover <a>Thing</a>s by filters defined on <a>Thing Description</a>s</li> |
| 255 | + <li>Discover <a>Thing</a>s by semantic filters</li> |
| 256 | + <li><a>Fetch and consume a TD</a> of a remote <a>Thing</a>.</li> |
257 | 257 | <li>On a consumed <a>Thing</a>,
|
258 | 258 | <ul>
|
259 |
| - <li>Get a property value.</li> |
260 |
| - <li>Set a property value.</li> |
| 259 | + <li>Get the value of a property or set of properties.</li> |
| 260 | + <li>Set the value of a property or a set of properties.</li> |
261 | 261 | <li>Invoke an action.</li>
|
262 | 262 | <li>
|
263 | 263 | Observe events.
|
|
277 | 277 | </li>
|
278 | 278 | <li>Retrieve a thing that is exposed by the local runtime</li>
|
279 | 279 | <li>Create and expose a local <a>Thing</a> based on a <a>Thing Description</a>.</li>
|
280 |
| - <li>Programmatically create and expose a local <a>Thing</a>. This may include the following operations: |
| 280 | + <li>Programmatically create and expose a local <a>Thing</a>. This may include the following use cases: |
281 | 281 | <ul>
|
282 | 282 | <li>Register the Thing.</li>
|
283 | 283 | <li>Unregister the Thing.</li>
|
|
289 | 289 | <li>Attach semantic information to an action</li>
|
290 | 290 | <li>Attach semantic information to a property</li>
|
291 | 291 | <li>Attach semantic information to an event</li>
|
292 |
| - <li>Register a handler for external requests to retrieve the <a>Thing Description</a>.</li> |
293 |
| - <li>Register a handler for external requests to add a listener to an event.</li> |
294 |
| - <li>Handle an external request to remove an event listener.</li> |
295 |
| - <li>Handle an external request to run an action: take the parameters from the request, execute the defined action, and return the result.</li> |
| 292 | + <li>Register handlers for external requests: |
| 293 | + <ul> |
| 294 | + <li>to fetch the <a>Thing Description</a>;</li> |
| 295 | + <li>to run an action: take the parameters from the request, execute the defined action, and return the result;</li> |
| 296 | + <li>to add a listener to an event;</li> |
| 297 | + <li>to remove an event listener.</li> |
| 298 | + </ul> |
| 299 | + </li> |
296 | 300 | <li>Emit an event, i.e. notify all listeners subscribed to that event.</li>
|
297 | 301 | </ul>
|
298 | 302 | </li>
|
|
420 | 424 | ExposedThing addAction(ThingAction action);
|
421 | 425 | ExposedThing addEvent(ThingEvent event);
|
422 | 426 |
|
423 |
| - ExposedThing onInvokeAction(DOMString actionName, ThingActionHandler callback); |
424 |
| - ExposedThing onUpdateProperty(DOMString propertyName, ThingPropertyChangeListener callback); |
425 |
| - |
426 | 427 | Promise<void> register();
|
427 | 428 | Promise<void> unregister();
|
428 | 429 |
|
429 | 430 | Promise<void> start();
|
430 | 431 | Promise<void> stop();
|
431 | 432 |
|
432 | 433 | Promise<void> emitEvent(DOMString eventName, any payload);
|
| 434 | + |
| 435 | + // define request handlers |
| 436 | + ExposedThing onPropertyRetrieve(PropertyRetrieveHandler handler); |
| 437 | + ExposedThing onPropertyUpdate(PropertyHandler handler); |
| 438 | + |
| 439 | + ExposedThing onActionInvocation(ActionHandler handler); |
| 440 | + |
| 441 | + ExposedThing onObserve(DOMString event, ObserveHandler handler); |
| 442 | + ExposedThing onUnobserve(DOMString event, UnobserveHandler handler); |
433 | 443 | };
|
434 | 444 |
|
435 | 445 | ExposedThing implements ConsumedThing;
|
436 | 446 |
|
| 447 | + callback PropertyRetrieveHandler = void (ThingProperty property, USVString url); |
| 448 | + callback PropertyUpdateHandler = void (ThingProperty property, USVString url); |
| 449 | + callback ActionHandler = void (ThingAction action, USVString url); |
| 450 | + callback ObserveHandler = void (DOMString eventName, USVString url); |
| 451 | + |
437 | 452 | dictionary SemanticType {
|
438 | 453 | DOMString name;
|
439 | 454 | DOMString context;
|
|
444 | 459 | object inputType;
|
445 | 460 | object outputType;
|
446 | 461 | SemanticType[] semanticTypes;
|
| 462 | + Function action; |
| 463 | + sequence<any> parameters; |
| 464 | + any returnValue; |
447 | 465 | };
|
448 | 466 |
|
449 | 467 | dictionary ThingProperty {
|
|
458 | 476 | object payloadType;
|
459 | 477 | SemanticType[] semanticTypes;
|
460 | 478 | };
|
461 |
| - |
462 |
| - callback ThingActionHandler = void (ThingAction action); |
463 |
| - |
464 |
| - callback ThingPropertyChangeListener = void(ThingProperty property); |
465 | 479 | </pre>
|
466 | 480 | </section>
|
467 | 481 |
|
|
0 commit comments