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

Multiple things per WebSocket #46

Open
bbangert opened this issue Jan 10, 2018 · 5 comments · May be fixed by #142
Open

Multiple things per WebSocket #46

bbangert opened this issue Jan 10, 2018 · 5 comments · May be fixed by #142
Projects

Comments

@bbangert
Copy link

When a websocket endpoint is acting as a gateway/adapter to many Web Things, it'd be ideal to have a single websocket connection to the gateway. This could be handled by including a URL in the message indicating what it went to, etc.

@benfrancis benfrancis changed the title Define websocket gateway API Multiple things per WebSocket Apr 3, 2018
@benfrancis
Copy link
Member

I agree it should be possible to have multiple things per WebSocket, as you say we just need to provide a thing ID (URI) in each message to indicate which thing it refers to.

@YonasJ
Copy link

YonasJ commented Mar 4, 2019

I would like to bump this idea.

When implementing the API using the arduino API's for the ESP32 I have encountered some challenges:

  • The API's don't really support handling the websockets dynamically. So, it is a fair bit of extra coding to create an end point for each URL.
  • Each websocket uses a fair amount of the precious memory available.
  • I had to do a lot of duplication to support the HTTP and WebSocket API.

I will put some comments in "Implement a single Websocket endpoint for things #947" as well.

@benfrancis
Copy link
Member

Proposal: Add an id field to WebSocket messages whose value is a URI identifying the thing the message relates to.

{
  "id": "http://mythingserver.com/things/robot1"
  "messageType": "setProperty",
  "data": {
    "leftMotor": 100
  }
}

We also need to figure out how to expose the WebSocket endpoint as currently we do this in the links member of a Thing resource which corresponds to a single Thing.

Perhaps if there is a Gateway capability the Thing Description for the gateway itself can have a top level links member which can link to a WebSocket endpoint for the whole gateway.

@benfrancis
Copy link
Member

Note that the W3C spec already has an id member for a Thing which is a URI identifying the Thing. This can optionally be the URL of the Thing Description.

See also: #29

@mrstegeman mrstegeman added this to Inbox in WebThings Gateway Mar 26, 2019
@hobinjk
Copy link

hobinjk commented Jul 30, 2019

As per the meeting today, this should come with a section or equivalent note that opening a websocket on /things will make a websocket corresponding to multiple things.

This could be considered part of a Gateway capability

hobinjk added a commit to hobinjk/wot that referenced this issue Aug 22, 2019
Fix WebThingsIO#46

Mirrors current gateway implementation. Also documents optional addition
of `id` to WS messages.
@hobinjk hobinjk linked a pull request Aug 22, 2019 that will close this issue
@mrstegeman mrstegeman moved this from Inbox to Review in WebThings Gateway Aug 22, 2019
@mrstegeman mrstegeman added this to Review in progress in Website Dec 2, 2020
@mrstegeman mrstegeman removed this from Review in WebThings Gateway Dec 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Website
Review in progress
Development

Successfully merging a pull request may close this issue.

4 participants