etc/browser-demo/src/index.js
function bootWebWorker({ Worker }) {
  const webWorker = Object.assign(
    new Worker("pubcontrol-browser-demo.webworker.js"),
    {
      onmessage: event => {
        console.debug("Message received from worker", event.data.type, event);
      }
    }
  );
  webWorker.postMessage({
    type: "Hello",
    from: "browser",
    content: "Hello worker. I booted you out here in pubcontrol-browser-demo."
  });
  const url = new URL(global.location.href);
  const epcp = {
    uri: url.searchParams.get("epcp.uri"),
    defaultChannel: url.searchParams.get("epcp.defaultChannel")
  };
  if (![epcp.uri, epcp.defaultChannel].every(Boolean)) {
    console.warn(
      "Missing one of ?epcp.uri or ?epcp.defaultChannel query params."
    );
  }
  webWorker.postMessage({
    type: "EPCPConfiguration",
    ...epcp
  });
}
function bootWebWorker({ Worker }) {
  const webWorker = Object.assign(
    new Worker("pubcontrol-browser-demo.webworker.js"),
    {
      onmessage: event => {
        console.debug("Message received from worker", event.data.type, event);
      }
    }
  );
  webWorker.postMessage({
    type: "Hello",
    from: "browser",
    content: "Hello worker. I booted you out here in pubcontrol-browser-demo."
  });
  const url = new URL(global.location.href);
  const epcp = {
    uri: url.searchParams.get("epcp.uri"),
    defaultChannel: url.searchParams.get("epcp.defaultChannel")
  };
  if (![epcp.uri, epcp.defaultChannel].every(Boolean)) {
    console.warn(
      "Missing one of ?epcp.uri or ?epcp.defaultChannel query params."
    );
  }
  webWorker.postMessage({
    type: "EPCPConfiguration",
    ...epcp
  });
}
function bootWebWorker ( { Worker } ) { const webWorker = Object . assign ( new Worker ( "pubcontrol-browser-demo.webworker.js" ) , { onmessage : event => { console . debug ( "Message received from worker" , event . data . type , event ) ; } } ) ; webWorker . postMessage ( { type : "Hello" , from : "browser" , content : "Hello worker. I booted you out here in pubcontrol-browser-demo." } ) ; const url = new URL ( global . location . href ) ; const epcp = { uri : url . searchParams . get ( "epcp.uri" ) , defaultChannel : url . searchParams . get ( "epcp.defaultChannel" ) } ; if ( ! [ epcp . uri , epcp . defaultChannel ] . every ( Boolean ) ) { console . warn ( "Missing one of ?epcp.uri or ?epcp.defaultChannel query params." ) ; } webWorker . postMessage ( { type : "EPCPConfiguration" , ... epcp } ) ; }
Create and initialize the browser-demo web worker in a DOM Worker.
Send the worker some configuration from this url's query params.
Create and initialize the browser - demo web worker in a DOM Worker . Send the worker some configuration from this url s query params .