Skip to content

Commit 48ad48e

Browse files
authored
Merge pull request #7 from zolkis/master
Add use cases. Refactor WebIDL.
2 parents 414342c + cf2c998 commit 48ad48e

File tree

1 file changed

+78
-37
lines changed

1 file changed

+78
-37
lines changed

index.html

Lines changed: 78 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -251,36 +251,54 @@
251251
<p>
252252
The following scripting use cases are covered in this specification:
253253
<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>
257257
<li>On a consumed <a>Thing</a>,
258258
<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>
261261
<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>
264276
</ul>
265277
</li>
266278
<li>Retrieve a thing that is exposed by the local runtime</li>
267279
<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:
269281
<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>.
270286
<li>Add a property definition to the <a>Thing</a>.</li>
271287
<li>Add an event definition to the <a>Thing</a>.</li>
272288
<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>
282292
<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>
284302
</ul>
285303
</li>
286304
</ul>
@@ -365,17 +383,15 @@
365383
interface WoT {
366384
Promise&lt;void&gt; discover(ThingFilter filter, ThingDiscoveryCallback onfound);
367385

368-
Promise&lt;ConsumedThing&gt; consumeDescription(object thingDescription);
369-
Promise&lt;ConsumedThing&gt; consumeDescriptionUri(DOMString thingDescriptionURI);
386+
Promise&lt;ConsumedThing&gt; retrieve((USVString or Dictionary) thingReference);
370387

371-
Promise&lt;ExposedThing&gt; createThing(DOMString name);
372-
Promise&lt;ExposedThing&gt; createFromDescription(object thingDescription);
373-
Promise&lt;ExposedThing&gt; createFromDescriptionUri(DOMString thingDescriptionURI);
388+
Promise&lt;ExposedThing&gt; createThing(ThingInit init);
374389
};
375390

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;
379395
};
380396

381397
callback ThingDiscoveryCallback = void (ConsumedThing thing);
@@ -384,10 +400,15 @@
384400

385401
<section> <h2>The Thing Client API</h2>
386402
<pre class="idl">
387-
interface ConsumedThing: Thing {
388-
Promise&lt;any&gt; invokeAction(DOMString actionName, any parameter);
389-
Promise&lt;any&gt; setProperty(DOMString propertyName, any newValue);
390-
Promise&lt;any&gt; getProperty(DOMString propertyName);
403+
interface ConsumedThing {
404+
readonly attribute DOMString name;
405+
readonly attribute USVString url;
406+
readonly attribute object description;
407+
408+
Promise&lt;void&gt; invokeAction(ThingAction action);
409+
Promise&lt;void&gt; setProperty(ThingProperty property);
410+
Promise&lt;void&gt; getProperty(ThingProperty property);
411+
391412
ConsumedThing addListener(DOMString eventName, ThingEventListener listener);
392413
ConsumedThing removeListener(DOMString eventName, ThingEventListener listener);
393414
ConsumedThing removeAllListeners(DOMString eventName);
@@ -399,17 +420,38 @@
399420

400421
<section> <h2>The Thing Server API</h2>
401422
<pre class="idl">
402-
interface ExposedThing: Thing {
423+
interface ExposedThing {
403424
ExposedThing addProperty(ThingProperty property);
404425
ExposedThing addAction(ThingAction action);
405426
ExposedThing addEvent(ThingEvent event);
427+
428+
Promise&lt;void&gt; register();
429+
Promise&lt;void&gt; unregister();
430+
431+
Promise&lt;void&gt; start();
432+
Promise&lt;void&gt; stop();
433+
406434
Promise&lt;void&gt; 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);
409446
};
410447

411448
ExposedThing implements ConsumedThing;
412449

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+
413455
dictionary SemanticType {
414456
DOMString name;
415457
DOMString context;
@@ -420,6 +462,9 @@
420462
object inputType;
421463
object outputType;
422464
SemanticType[] semanticTypes;
465+
Function action;
466+
sequence&lt;any&gt; parameters;
467+
any returnValue;
423468
};
424469

425470
dictionary ThingProperty {
@@ -434,10 +479,6 @@
434479
object payloadType;
435480
SemanticType[] semanticTypes;
436481
};
437-
438-
callback ThingActionHandler = void (ThingAction action);
439-
440-
callback ThingPropertyChangeListener = void(ThingProperty property);
441482
</pre>
442483
</section>
443484

0 commit comments

Comments
 (0)