-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Currently, it seems that WoT consumers have to know in advance the protocol binding of a Thing. If a Thing has both an HTTP and a CoAP binding, a consumer has to decide statically whether to instantiate a TDHttpRequest or a TDCoapRequest from each form.
Would it be possible to instantiate a generic object representing a request (or, in the WoT terminology, an operation)? Here is a suggestion:
Optional<PropertyAffordance> humidity = td.getPropertyByName("humidity");
if (humidity.isPresent()) {
Optional<Form> form = humidity.get().getFirstFormForOperationType(TD.readProperty);
if(form.isPresent()) {
// here is the proposal
Operation op = ProtocolBindingFactory.bind(form.get(), TD.readProperty);
op.setPayload();
Response response = op.execute();
// the response's interface is generic, it may include properties of the Expected Response class and a 'payload' property represented as JSON, as current TDHttpResponse objects
}
}Protocol bindings may register themselves to ProtocolBindingFactory.
Metadata
Metadata
Assignees
Labels
No labels