-
Notifications
You must be signed in to change notification settings - Fork 28
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
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
46b6108
Add use case for register/unregister ExposedThing. Refactor WebIDL de…
zolkis 16d6239
Reformulated use cases for hooks to use actions triggered on a condit…
zolkis 1e2d777
To #6, reformulate observation use cases based on comments and discus…
zolkis d77834a
To #6, update Web IDL to conform to the use cases
zolkis cf2c998
Add use case and Web IDL definition for semantic translate handler of…
zolkis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
|
@@ -365,17 +368,15 @@ | |
interface WoT { | ||
Promise<void> discover(ThingFilter filter, ThingDiscoveryCallback onfound); | ||
|
||
Promise<ConsumedThing> consumeDescription(object thingDescription); | ||
Promise<ConsumedThing> consumeDescriptionUri(DOMString thingDescriptionURI); | ||
Promise<ConsumedThing> retrieve((USVString or Dictionary) thingReference); | ||
|
||
Promise<ExposedThing> createThing(DOMString name); | ||
Promise<ExposedThing> createFromDescription(object thingDescription); | ||
Promise<ExposedThing> createFromDescriptionUri(DOMString thingDescriptionURI); | ||
Promise<ExposedThing> 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); | ||
|
@@ -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<any> invokeAction(DOMString actionName, any parameter); | ||
Promise<any> setProperty(DOMString propertyName, any newValue); | ||
Promise<any> getProperty(DOMString propertyName); | ||
|
||
ConsumedThing addListener(DOMString eventName, ThingEventListener listener); | ||
ConsumedThing removeListener(DOMString eventName, ThingEventListener listener); | ||
ConsumedThing removeAllListeners(DOMString eventName); | ||
|
@@ -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<void> emitEvent(DOMString eventName, any payload); | ||
|
||
ExposedThing onInvokeAction(DOMString actionName, ThingActionHandler callback); | ||
ExposedThing onUpdateProperty(DOMString propertyName, ThingPropertyChangeListener callback); | ||
|
||
Promise<void> register(); | ||
Promise<void> unregister(); | ||
|
||
Promise<void> start(); | ||
Promise<void> stop(); | ||
|
||
Promise<void> emitEvent(DOMString eventName, any payload); | ||
}; | ||
|
||
ExposedThing implements ConsumedThing; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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"?
There was a problem hiding this comment.
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?