Skip to content

Consider ways of supporting observing binary properties #3272

@benfrancis

Description

@benfrancis

As a developer I want to be able to observe a binary property without base64 encoding it so that the operation is more efficient.

Currently the gateway incorrectly adds observeproperty Forms using SSE for properties, even if they use a contentType other than JSON (e.g. an ImageProperty). This is incorrect because binary payloads can not currently be observed over SSE unless they are base64 encoded. But maybe we should think about ways to make this possible...

From a discussion on the WoT Community Discord:

You want to observe an image?
Hmm, a few options:

  1. The oldschool way used by IP cameras to stream MJPEG - use the multipart/x-mixed-replace Content-type header to tell the client you're going to keep sending a series of separate images and the client should keep replacing the image with a new one. I've never tried this but I think it's natively supported by the element in web browsers, if that's how you're displaying the received images.
  2. WebSockets - The server can push binary data whenever it wants (just not mixed inside a text-based message). This is more efficient but requires some work on the client-side to handle the binary blobs and update the DOM.
  3. Server-Sent Events - SSE is text-only so you would have to base64 encode the images. Not very efficient but easier to implement than WebSockets as the client automatically handles reconnection.

See also: w3c/web-thing-protocol#119

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions