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
appid
is the ID of the application to launchdata
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:
It is highly recommended to have the response id checked, because it may also get triggered when there is an another OLP process ongoing.
Using OLP as a trigger
To interpret OLP requests and return data to requesters, apps need to have this following method in their source file:
Basically, what we are doing here is to check for window params, if any, to find out that if theres a request in the launch of the process, and the request of for the ID of the current application.
Which means that we simply check every time if there's an OLP requests, simply put, params in the myWindow
object matches our current app ID.
We also need to store the requesting window UID to 'respond' or to return any data.
Returning OLP requests
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