Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

After sending the data we will receive a response from the unreal app. This response can be caught by using window.e3ds.onEvent function. Here’s an example of that -

Code Block
function HandleResponseFromUE4(jsonObj)//process whatever u want to do with your object
{
  console.log(jsonObj);
  
  if(window.e3ds.onEvent("increaseSessionExpireTime", (dataevents[jsonObj.cmd]){
    window.e3ds.events[jsonObj.cmd](jsonObj);
  }
}


//eagle3dstreaming's Server   to Iframe communication
const eventHandler = (event) => {
    console.log("Increasing session expire time", 'Message From SS -- > Iframe  ', event.data);

     if (!event.data.type) // Example of iframe
    let iframe = document.createElement("iframe");
    iframe.src="http://example.com";
    iframe.classList.add("iframeStyle");
    iframe.style.display = "block";
    document.getElementsByTagName("body")[0].append(iframe);

    // Example of a button
    let button1 = document.createElement("button");
    button1.innerText = "Close Iframe";
    button1.classList.add("closeButtonOfIframe");
    button1.addEventListener("click", (ev) => {
        iframe.style.display = "none";
    });
    document.getElementsByTagName("body")[0].append(button1);
}); is it a data not from server
  {
    console.log('Message From UE4-- > Iframe  :', event.data);
    if(typeof event.data === 'string' && event.data.includes('cmd')){
      const parsedData = JSON.parse(event.data);
      if (parsedData.cmd){//than is it a data from ue4 ???
        HandleResponseFromUE4(parsedData)//process the data sent by ue4
      }
    }
    
  }
}

window.addEventListener("message", eventHandler);

Part-4 :
Set Custom Resolution from Webpage with Iframe

...