Skip to content

[ExposedThing] Not possible to handle property observations in Scripting level #211

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

Closed
egekorkan opened this issue Apr 6, 2020 · 4 comments

Comments

@egekorkan
Copy link
Contributor

Similar to Issue #210

Use case: A reverse proxy implementation consumes a physical Thing in a local network and reexposes it as a new virtual ExposedThing to another network. A consumer of the virtual ExposedThing starts observing a property. The issue is that there is no way to detect and handle a new observer so that the proxy can start observing a property in the physical Thing. A non-optimal solution is to observe properties of the physical Thing in the beginning (without any subscription) and write new values into the properties of the virtual ExposedThing, which results in the new values being sent to the Consumer.

Proposal: Create two new methods in the ExposedThing interface, one to handle the observeproperty operation and one to handle unobserveproperty. These could be similar to setPropertyReadHandler. Example:

  • setPropertyObserveHandler(propertyName, ? observerCount): This could also solve the handling of subscription payloads. A subscription count would be interesting if the implementation wants to limit the number of subscriptions due to resource

  • setPropertyUnobserveHandler(eventName, ? observerCount): Similar to the above

@zolkis
Copy link
Contributor

zolkis commented Apr 6, 2020

What is the use case to handle observerCount? The only thing needed is registering a request handler.

partial interface ExposedThing {
   Promise<void> setPropertyObserveHandler(DOMString name, PropertyReadHandler handler);
   Promise<void> setPropertyUnobserveHandler(DOMString name, PropertyReadHandler handler);
};

The signature is the same as for PropertyReadHandler. We may change the name. The callback returns the last known value of the Property.

@zolkis
Copy link
Contributor

zolkis commented Apr 20, 2020

I have made these changes, but have doubts about do we really need script defined handlers for subscriptions. When writing the algorithms, I realized that implementations can trivially do/generate the code for that, which is the reason these have not been included from the start.

So we need to check if we have the same understanding on how observe should be implemented and what is the value to open a hook for apps.

@zolkis
Copy link
Contributor

zolkis commented Apr 20, 2020

On the Scripting call on 20. April 2020, we clarified that these handlers would not just extend default handling, but completely define it.

zolkis added a commit to zolkis/wot-scripting-api that referenced this issue Jun 4, 2020
@zolkis
Copy link
Contributor

zolkis commented Jun 18, 2020

Fixed by #218

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants