w3c / wot-binding-templates

Web of Things (WoT) Binding Templates
http://w3c.github.io/wot-binding-templates/
Other
22 stars 25 forks source link

Server-Sent Events (SSE) Binding Template #361

Open benfrancis opened 2 months ago

benfrancis commented 2 months ago

Coming from discussions about Profiles 1.0, I would like to propose a binding template for Server-Sent Events (SSE), either as part of the HTTP Binding Template or a separate document.

Protocol Binding Template

For 1.x the key thing I think needs specifying is a default HTTP method for the subscribeevent and observeproperty operations when subprotocol is set to sse:

op value Default Binding
subscribeevent "htv:methodName": "GET"
observeproperty "htv:methodName": "GET"

(See also: #330).

Note that unsubscribing/unobserving in SSE just involves dropping the HTTP connection, so a note could be added to that effect.

It might also be a good idea to explicitly say that the default content-type when subprotocol is set to sse should be text/event-stream.

Payload Binding Template

Beyond that, I also think we need a payload binding for the text/event-stream content type which as a minimum says:

(See also: #347 regarding how to override the default nested content type).

I'm not sure whether both the protocol binding and payload binding should be specified in the same document, or separate documents.

WoT 2.0

For WoT 2.0, I hope this binding template can be expanded into a "Server-Sent Events Protocol Binding" document which replaces (through defaults) the whole of the protocol binding for the current HTTP SSE Profile.

If observeable action operations are added to the Thing Description specification in the future, this could also be covered.