The Open Launch Protocol

What is Open Launch Protocol (OLP)?

OLP is a method to open local applications but also carrying some data in the process. Unlike the EventBusWorker, OLP can launch an application from a file ID and transmit data to it.

But even though OLP can launch any app, it doesn't mean that all apps will respond to the given information. OLP needs receiver side listeners for it to work.

With OLP, you can make 'Open file' popups or even create an app that runs a custom file extension! The possibilities are pretty much endless!

OLP, relies on cross-origin communication based on window.postMessage API and the "message" event listener.

Using OLP

const currentreqID = window.parent.genUID();
window.parent.openlaunchprotocol(appid, data, id, winuid);
  • appid is the ID of the application to launch

  • data can be anything you need to transmit.

  • id must be a UID string. It is used to handle multiple requests.

  • winuid will be the ID of the window where the response should be transmitted to.

Receiving OLP returns

Here is a code snippet on how to receive an OLP return:

window.addEventListener('message', (event) => {
  if (event.data.id === myWindow.windowID) {
    let result = event.data.returned;
    console.log(result);
  }
});

Using OLP as a trigger

To interpret OLP requests and return data to requesters, apps need to have the following method in their source file:

async function greenflag() {
  if (myWindow.params) {
    // interpret the data
    sessionReqID = myWindow.params.trid;
    console.log(myWindow.params.data);
  }
}

We also require apps to save the sessionReqID (myWindow.params.trid) as it is requird to return any Data. You can ignore it if the app handler doesnt return anything.

Returning OLP requests

window.parent.OLPreturn(data, sessionReqID)
  • sessionReqID is the requestor window UID we saved when the application got triggered of OLP.

The OLPreturn function can be used anywhere in your appliction allowing time intensive operations to get carried out.

Last updated

Was this helpful?