webstream sample

Ouistiti needs specific configuration for streaming:

    webstream = {
        docroot = "srv/www/webstream";
        options = "multipart";
        fps = 30;
    };
    

simple streamer

A simple streamer is available with the Ouistiti's utils. It sends simple json packets to a UNIX socket

The Webstream's module supports mutlipart/x-mixed-replace content with the following configuration

        options = "multipart";
        
streamer -U -n data.json -R srv/www/webstream

webstreammultipart.js offers the fetchmultipart(url) to receive and parse the stream

        function read(reader) {
          reader.read()
          .then(function({done, value}) {
            if (done)
            {
              throw Error("Connection closed");
            }
            if (value.headers.get("Content-Type") != "text/json")
            {
              throw Error("Message Not a JSON");
            }
            return value.json();
          })
          .then(function(json) {
            let field = document.querySelector("#value");
            field.setAttribute("value", json.data);
            read(reader);
          })
        }
        fetchmultipart("data.json")
        .then(function(rs) {
          let reader = rs.getReader();
          read(reader);
        })
        .catch(function(error) {
        console.log(error.message);
        });