|
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 |
| - <li>Add a listener to an event.</li> |
263 |
| - <li>Remove a listener from an event.</li> |
| 262 | + <li> |
| 263 | + Observe events. |
| 264 | + <ul> |
| 265 | + <li>Add a listener to an event.</li> |
| 266 | + <li>Remove a listener from an event.</li> |
| 267 | + </ul> |
| 268 | + Default events are the following: |
| 269 | + <ul> |
| 270 | + <li>A property has changed.</li> |
| 271 | + <li>An action has been invoked.</li> |
| 272 | + <li>Other Things have added an event listener.</li> |
| 273 | + <li><a>Thing Description</a> has changed, i.e. properties, events or actions have been defined, removed, or the definition has changed.</li> |
| 274 | + </ul> |
| 275 | + </li> |
264 | 276 | </ul>
|
265 | 277 | </li>
|
266 | 278 | <li>Retrieve a thing that is exposed by the local runtime</li>
|
267 | 279 | <li>Create and expose a local <a>Thing</a> based on a <a>Thing Description</a>.</li>
|
268 |
| - <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: |
269 | 281 | <ul>
|
| 282 | + <li>Register the Thing.</li> |
| 283 | + <li>Unregister the Thing.</li> |
| 284 | + <li>Start the exposed <a>Thing</a> in order to process external requests.</li> |
| 285 | + <li>Stop the exposed <a>Thing</a>. |
270 | 286 | <li>Add a property definition to the <a>Thing</a>.</li>
|
271 | 287 | <li>Add an event definition to the <a>Thing</a>.</li>
|
272 | 288 | <li>Add an action definition to the <a>Thing</a>.</li>
|
273 |
| - <li>Attach semantic information to an Action</li> |
274 |
| - <li>Attach semantic information to a Property</li> |
275 |
| - <li>Attach semantic information to an Event</li> |
276 |
| - <li>Start the exposed <a>Thing</a> in order to process external requests.</li> |
277 |
| - <li>Modify the handling of an external request to retrieve the <a>Thing Description</a>.</li> |
278 |
| - <li>React on a property change</li> |
279 |
| - <li>Handle an external request to add a listener to an event.</li> |
280 |
| - <li>Handle an external request to remove a listener to an event.</li> |
281 |
| - <li>Handle an external request to run an action: take the parameters from the request, execute the defined action, and return the result.</li> |
| 289 | + <li>Attach semantic information to an action</li> |
| 290 | + <li>Attach semantic information to a property</li> |
| 291 | + <li>Attach semantic information to an event</li> |
282 | 292 | <li>Emit an event, i.e. notify all listeners subscribed to that event.</li>
|
283 |
| - <li>Stop the exposed <a>Thing</a>. |
| 293 | + <li>Register handlers for external requests: |
| 294 | + <ul> |
| 295 | + <li>to fetch the <a>Thing Description</a>;</li> |
| 296 | + <li>to run an action: take the parameters from the request, execute the defined action, and return the result;</li> |
| 297 | + <li>to add a listener to an event;</li> |
| 298 | + <li>to remove an event listener.</li> |
| 299 | + </ul> |
| 300 | + </li> |
| 301 | + <li>Register handler for semantic translation of property values.</li> |
284 | 302 | </ul>
|
285 | 303 | </li>
|
286 | 304 | </ul>
|
|
365 | 383 | interface WoT {
|
366 | 384 | Promise<void> discover(ThingFilter filter, ThingDiscoveryCallback onfound);
|
367 | 385 |
|
368 |
| - Promise<ConsumedThing> consumeDescription(object thingDescription); |
369 |
| - Promise<ConsumedThing> consumeDescriptionUri(DOMString thingDescriptionURI); |
| 386 | + Promise<ConsumedThing> retrieve((USVString or Dictionary) thingReference); |
370 | 387 |
|
371 |
| - Promise<ExposedThing> createThing(DOMString name); |
372 |
| - Promise<ExposedThing> createFromDescription(object thingDescription); |
373 |
| - Promise<ExposedThing> createFromDescriptionUri(DOMString thingDescriptionURI); |
| 388 | + Promise<ExposedThing> createThing(ThingInit init); |
374 | 389 | };
|
375 | 390 |
|
376 |
| - interface Thing { |
377 |
| - readonly attribute DOMString name; |
378 |
| - readonly attribute object description; |
| 391 | + dictionary ThingInit { |
| 392 | + DOMString name; |
| 393 | + USVString url; |
| 394 | + object description; |
379 | 395 | };
|
380 | 396 |
|
381 | 397 | callback ThingDiscoveryCallback = void (ConsumedThing thing);
|
|
384 | 400 |
|
385 | 401 | <section> <h2>The Thing Client API</h2>
|
386 | 402 | <pre class="idl">
|
387 |
| - interface ConsumedThing: Thing { |
388 |
| - Promise<any> invokeAction(DOMString actionName, any parameter); |
389 |
| - Promise<any> setProperty(DOMString propertyName, any newValue); |
390 |
| - Promise<any> getProperty(DOMString propertyName); |
| 403 | + interface ConsumedThing { |
| 404 | + readonly attribute DOMString name; |
| 405 | + readonly attribute USVString url; |
| 406 | + readonly attribute object description; |
| 407 | + |
| 408 | + Promise<void> invokeAction(ThingAction action); |
| 409 | + Promise<void> setProperty(ThingProperty property); |
| 410 | + Promise<void> getProperty(ThingProperty property); |
| 411 | + |
391 | 412 | ConsumedThing addListener(DOMString eventName, ThingEventListener listener);
|
392 | 413 | ConsumedThing removeListener(DOMString eventName, ThingEventListener listener);
|
393 | 414 | ConsumedThing removeAllListeners(DOMString eventName);
|
|
399 | 420 |
|
400 | 421 | <section> <h2>The Thing Server API</h2>
|
401 | 422 | <pre class="idl">
|
402 |
| - interface ExposedThing: Thing { |
| 423 | + interface ExposedThing { |
403 | 424 | ExposedThing addProperty(ThingProperty property);
|
404 | 425 | ExposedThing addAction(ThingAction action);
|
405 | 426 | ExposedThing addEvent(ThingEvent event);
|
| 427 | + |
| 428 | + Promise<void> register(); |
| 429 | + Promise<void> unregister(); |
| 430 | + |
| 431 | + Promise<void> start(); |
| 432 | + Promise<void> stop(); |
| 433 | + |
406 | 434 | Promise<void> emitEvent(DOMString eventName, any payload);
|
407 |
| - ExposedThing onInvokeAction(DOMString actionName, ThingActionHandler callback); |
408 |
| - ExposedThing onUpdateProperty(DOMString propertyName, ThingPropertyChangeListener callback); |
| 435 | + |
| 436 | + // define request handlers |
| 437 | + ExposedThing onPropertyRetrieve(PropertyRetrieveHandler handler); |
| 438 | + ExposedThing onPropertyUpdate(PropertyHandler handler); |
| 439 | + |
| 440 | + ExposedThing onActionInvocation(ActionHandler handler); |
| 441 | + |
| 442 | + ExposedThing onObserve(DOMString event, ObserveHandler handler); |
| 443 | + ExposedThing onUnobserve(DOMString event, UnobserveHandler handler); |
| 444 | + |
| 445 | + any onSemanticTranslate(Property property, SemanticType type); |
409 | 446 | };
|
410 | 447 |
|
411 | 448 | ExposedThing implements ConsumedThing;
|
412 | 449 |
|
| 450 | + callback PropertyRetrieveHandler = void (ThingProperty property, USVString url); |
| 451 | + callback PropertyUpdateHandler = void (ThingProperty property, USVString url); |
| 452 | + callback ActionHandler = void (ThingAction action, USVString url); |
| 453 | + callback ObserveHandler = void (DOMString eventName, USVString url); |
| 454 | + |
413 | 455 | dictionary SemanticType {
|
414 | 456 | DOMString name;
|
415 | 457 | DOMString context;
|
|
420 | 462 | object inputType;
|
421 | 463 | object outputType;
|
422 | 464 | SemanticType[] semanticTypes;
|
| 465 | + Function action; |
| 466 | + sequence<any> parameters; |
| 467 | + any returnValue; |
423 | 468 | };
|
424 | 469 |
|
425 | 470 | dictionary ThingProperty {
|
|
434 | 479 | object payloadType;
|
435 | 480 | SemanticType[] semanticTypes;
|
436 | 481 | };
|
437 |
| - |
438 |
| - callback ThingActionHandler = void (ThingAction action); |
439 |
| - |
440 |
| - callback ThingPropertyChangeListener = void(ThingProperty property); |
441 | 482 | </pre>
|
442 | 483 | </section>
|
443 | 484 |
|
|
0 commit comments