Skip to content

Add use cases. Refactor WebIDL. #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 14, 2017
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 32 additions & 18 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -267,20 +267,23 @@
<li>Create and expose a local <a>Thing</a> based on a <a>Thing Description</a>.</li>
<li>Programmatically create and expose a local <a>Thing</a>. This may include the following operations:
<ul>
<li>Register the Thing.</li>
<li>Unregister the Thing.</li>
<li>Start the exposed <a>Thing</a> in order to process external requests.</li>
<li>Stop the exposed <a>Thing</a>.
<li>Add a property definition to the <a>Thing</a>.</li>
<li>Add an event definition to the <a>Thing</a>.</li>
<li>Add an action definition to the <a>Thing</a>.</li>
<li>Attach semantic information to an Action</li>
<li>Attach semantic information to a Property</li>
<li>Attach semantic information to an Event</li>
<li>Start the exposed <a>Thing</a> in order to process external requests.</li>
<li>Modify the handling of an external request to retrieve the <a>Thing Description</a>.</li>
<li>React on a property change</li>
<li>Register an action triggered by external retrieve requests on the <a>Thing Description</a>.</li>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to avoid confusion with the interacion pattern "action" (of a thing) , could we say "a callback" or "logic"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we could use something different. Originally I've used "hook", since it serves a special purpose (server side code executed before/after the implementation invokes an action registered by a client).

However, I have deliberately changed it to "action", since the signature may be the same as for registering an action, and shouldn't it be part of the TD like Actions are?

So if we use a different word, e.g. "hook", it needs to be added to the interaction list, together with Actions, Properties and Events.

Another question: could we model this use case with special events that are triggered locally by a property change or action invocation?

And finally, as also asked in the issue: is there an other way to fulfill the use case?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to avoid confusion with the interacion pattern "action" (of a thing) , could we say "a callback" or "logic"?

<li>Register an action triggered on a property change.</li>
<li>Attach semantic information to an action</li>
<li>Attach semantic information to a property</li>
<li>Attach semantic information to an event</li>
<li>Handle an external request to retrieve the <a>Thing Description</a>.</li>
<li>Handle an external request to add a listener to an event.</li>
<li>Handle an external request to remove a listener to an event.</li>
<li>Handle an external request to run an action: take the parameters from the request, execute the defined action, and return the result.</li>
<li>Emit an event, i.e. notify all listeners subscribed to that event.</li>
<li>Stop the exposed <a>Thing</a>.
</ul>
</li>
</ul>
Expand Down Expand Up @@ -365,17 +368,15 @@
interface WoT {
Promise&lt;void&gt; discover(ThingFilter filter, ThingDiscoveryCallback onfound);

Promise&lt;ConsumedThing&gt; consumeDescription(object thingDescription);
Promise&lt;ConsumedThing&gt; consumeDescriptionUri(DOMString thingDescriptionURI);
Promise&lt;ConsumedThing&gt; retrieve((USVString or Dictionary) thingReference);

Promise&lt;ExposedThing&gt; createThing(DOMString name);
Promise&lt;ExposedThing&gt; createFromDescription(object thingDescription);
Promise&lt;ExposedThing&gt; createFromDescriptionUri(DOMString thingDescriptionURI);
Promise&lt;ExposedThing&gt; createThing(ThingInit init);
};

interface Thing {
readonly attribute DOMString name;
readonly attribute object description;
dictionary ThingInit {
DOMString name;
USVString url;
object description;
};

callback ThingDiscoveryCallback = void (ConsumedThing thing);
Expand All @@ -384,10 +385,15 @@

<section> <h2>The Thing Client API</h2>
<pre class="idl">
interface ConsumedThing: Thing {
interface ConsumedThing {
readonly attribute DOMString name;
readonly attribute USVString url;
readonly attribute object description;

Promise&lt;any&gt; invokeAction(DOMString actionName, any parameter);
Promise&lt;any&gt; setProperty(DOMString propertyName, any newValue);
Promise&lt;any&gt; getProperty(DOMString propertyName);

ConsumedThing addListener(DOMString eventName, ThingEventListener listener);
ConsumedThing removeListener(DOMString eventName, ThingEventListener listener);
ConsumedThing removeAllListeners(DOMString eventName);
Expand All @@ -399,13 +405,21 @@

<section> <h2>The Thing Server API</h2>
<pre class="idl">
interface ExposedThing: Thing {
interface ExposedThing {
ExposedThing addProperty(ThingProperty property);
ExposedThing addAction(ThingAction action);
ExposedThing addEvent(ThingEvent event);
Promise&lt;void&gt; emitEvent(DOMString eventName, any payload);

ExposedThing onInvokeAction(DOMString actionName, ThingActionHandler callback);
ExposedThing onUpdateProperty(DOMString propertyName, ThingPropertyChangeListener callback);

Promise&lt;void&gt; register();
Promise&lt;void&gt; unregister();

Promise&lt;void&gt; start();
Promise&lt;void&gt; stop();

Promise&lt;void&gt; emitEvent(DOMString eventName, any payload);
};

ExposedThing implements ConsumedThing;
Expand Down