eclipse-thingweb / eclipse-thingweb/node-wot

[binding-websockets] Current implementation missing certain functionality

Open
#476 6 comments 0 reactions 0 assignees View on GitHub
binding-websockets enhancement
Dominant language
TypeScript
Stars
192
Forks
100
Avg merge
3d 2h
Merged PRs (30d)
6

Description

**TLDR:** currently, `binding-websockets` does not handle properties, actions, nor meta-interactions

**In general, I believe `node-wot` should strive to provide an equal, complete implementation across all protocols (despite their intrinsic differences). In other words, [this table](https://github.com/eclipse/thingweb.node-wot/issues/213) should have as many checks as possible.**

I'm aware that the necessity of a WebSocket subprotocol in order to wrap websocket messages for the WebSocketServer to be able to route/handle incoming requests has been previously [discussed](https://github.com/eclipse/thingweb.node-wot/issues/128#issuecomment-545796340). Having said that, I'm not sure if the current `binding-websockets` implementation is in standby because of that or the missing features are simply pending to be implemented.

What appears to be missing (in comparisson with http and mqtt bindings at least, note some might actually not be desired):

1) **`ws://{host}:{port}/`** should return list of exposed things (`binding-mqtt` I think does not publish this list on initial connection. The `binding-http` though does indeed allow making a GET request to `http://{host}:{port}/` to fetch it)
2) **`ws://{host}:{port}/{title}`** should return the TD of the exposed thing (similar to how `binding-mqtt` publishes td on intial subscription to `{title}/#` topic, `binding-http` handles this via normal GET request to `http://{host}:{port}/{title}`)
3) **`ws://{host}:{port}/{title}/properties/{name}`** should handle readproperty, writeproperty, observeproperty, unobserveproperty
4) **`ws://{host}:{port}/{title}/actions/{name}`** should handle invokeaction
5) **`ws://{host}:{port}/{title}/all/properties`** should handle readallproperties, writeallproperties, observeallproperties, unobserveallproperties
6) **`ws://{host}:{port}/{title}/multiple/properties`** should handle readmultipleproperties and writemultipleproperties (NOTE: this might be done already, I couldn't find out if `/multiple/properties` or where?)
7) **other meta interactions** e.g. subscribeallevents, unsubscribeallevents `/all/events` but I think those have not yet been implemented in node-wot

Regarding the websocket subprotocol (might be more advanced discussions here already), something like this:
```json
{
"type": "writemultipleproperties",
"data": {
"temperature": 19,
"speed": 18
}
}
```
might be everything the server/client needs to correctly distinguish/identify messages.

But maybe a more complete, even standards-based implementation like [cloudevents](https://cloudevents.io/) might be worth it:
```json
{
"specversion": "1.0",
"type": "writemultipleproperties",
"id": "xxxx-xxxx-xxxx",
"source": "bigco.com",
"data": {
"temperature": 19,
"speed": 18
}
}
```

I see that the `binding-mqtt` is somewhat more complete (e.g. it already handles properties and actions). I could maybe provide a PR if similar functionality (and that mentioned in 1-7 above) is indeed desired for `binding-websockets` as well.

Thanks!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.