Skip to content
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

ProtocolClient Interface does not allow to specify the affordance name, if the information is not contained in the Form #1342

Open
RobWin opened this issue Dec 19, 2024 · 4 comments
Labels
core Issues with the core library enhancement New feature or request

Comments

@RobWin
Copy link

RobWin commented Dec 19, 2024

The implementation of the ProtocolClient methods in node-wot assume that all the information needed to read a property, invoke an action or subscribe to an event is contained in a Form. See https://github.com/eclipse-thingweb/node-wot/blob/master/packages/core/src/protocol-interfaces.ts#L48
When implementing a websocket binding based on the Webthingprotocol, we saw that this is not the case for all protocols.
We had a long discussion on Discord about it. And in the Webthingprotocol spec the form href will not contain a property name or action name, so we would need to overload ProtocolClient methods with additional versions which also take the names as an input parameter.

@RobWin RobWin changed the title ProtocolClient Interface does not allow to specify the propertyName, actionName or eventName, if the information is not contained in the Form ProtocolClient Interface does not allow to specify the affordance name, if the information is not contained in the Form Dec 19, 2024
@danielpeintner
Copy link
Member

It seems that the readResource() / writeResource() / invokeResource() / invokeResource() / unlinkResource() method calls could be extended to hand in the interaction name.

Having said that, I wonder what is the best way forward with the following aspects in mind:

  • most bindings don't need it..
  • failure cases: property names might be different.. What should happen?
  • backward compatibility (adding and optional argument or require this new argument)
    • if optional, failing if needed?
    • more aspects?
  • is the name of an interaction enough, or might we need to add more (maybe in the future?) --> adding an (optional) object instead?

Any opinions?

@danielpeintner danielpeintner added enhancement New feature or request core Issues with the core library labels Dec 19, 2024
@RobWin
Copy link
Author

RobWin commented Dec 19, 2024

In kotlin-wot I modified ConsumedThing.readProperty to call client.readResource(affordanceName, form).
In the ProtocolClient I added a new overloaded method with a default implementation.

  suspend fun readResource(resourceName: String, form: Form): Content {
      return readResource(form)
  }

Thus I didn't have to modify existing bindings, but can override this new method in the WebsocketProtocolClient.

But Typescript cannot have default implementations in interfaces or?

But I agree a single Resource object as an input parameter would be more flexible to extend, but it would introduce a lot of optional fields. But that would be fine, since the ProtocolClient implementation could use the fields it requires.
The Resource object could contain a name, form and in the future additional information. Maybe tracing context metadata which needs to be added to a protocol request?
Right now the protocol client does not allow a ConsumedThing implementation to attach additional tracing context to a protocol communication.
I actually prefer to have an object as an input parameter instead of a list of individial parameters 👍

@JKRhb
Copy link
Member

JKRhb commented Dec 19, 2024

In dart_wot, I actually had a similar problem and solved it (for now) using an additional AugmentedForm class, that contains references to both the related interaction affordance and Thing Description. Having a best practice here across implementations would definitely be nice.

@RobWin
Copy link
Author

RobWin commented Dec 19, 2024

Indeed, we need an object (or AugmentedForm), because the thingId is also required in the WebthingProtocol websocket messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Issues with the core library enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants