WebThingsIO / gateway

WebThings Gateway - a self-hosted web application for monitoring and controlling a building over the web
http://webthings.io/gateway
Mozilla Public License 2.0
2.61k stars 339 forks source link

Change WebSocket endpoints from links to forms in Thing Descriptions #2882

Open benfrancis opened 3 years ago

benfrancis commented 3 years ago

I think the W3C WoT Working Group's conclusion in https://github.com/w3c/wot-thing-description/issues/878 is that it's OK to have a single top level form for a WebSocket endpoint, with no op member.

This means that if we want to we can change the current top level link for WebSocket endpoints exposed by the gateway:

    "links": [
        {
            "rel": "alternate",
            "href": "ws://localhost:8080/things/virtual-things-10"
        }
    ],

into a form:

    "forms": [
        {
            "href": "ws://localhost:8080/things/virtual-things-10"
        }
    ],
benfrancis commented 2 years ago

think the W3C WoT Working Group's conclusion in w3c/wot-thing-description#878 is that it's OK to have a single top level form for a WebSocket endpoint, with no op member.

This is no longer the case, see https://github.com/w3c/wot-thing-description/issues/1192#issuecomment-971432107.

  1. Forms are mandatory for all interaction affordances
  2. The op member is considered a mandatory (with defaults) of all forms
  3. A top level form is limited to a finite set of operation types which only includes meta operations

The upshot of this is that we either need to:

  1. Add a form to every individual interaction affordance which specifies the same WebSocket URL but different op values
  2. Leave WebSocket endpoints as links rather than forms

The former creates a lot of redundancy and duplication of metadata and there isn't a clear mapping of operations onto the current Web Thing WebSocket sub-protocol.

The latter is much simpler but is unlikely to be understood by third party WoT consumers.

I'm tempted to leave them as links for now, and switch to forms once the Web Thing Protocol Community Group has a W3C version of the WebSocket subprotocol which better maps onto the set of WoT operations and can ultimately be formally registered as a WebSocket subprotocol with IANA.

benfrancis commented 1 year ago

Note that there is some work planned in the next WoT Working Group charter to better support re-usable connections to enable less verbose Thing Descriptions (in WoT Thing Description 2.0), see https://w3c.github.io/wot-charter-drafts/wot-wg-2023-details.html#init-connection-workitem