OpenFin's context sharing features have proven to be quite useful, as they connect views and apps within a platform in powerful ways. OpenFin platforms are great ways to build high quality suites of applications that empower users and organizations. But, out-of-the-box, context sharing only works within a single platform.
If users of your OpenFin platform also have another application's OpenFin platform installed, wouldn't it be great to enable context sharing between those two platforms?
There is a way.
We at OpenFin have an easy-to-implement solution to context sharing between two OpenFin platforms. We wrote overrides of specific Interop functions that you can copy-and-paste into your own platform code to enable context sharing between two separate OpenFin platforms.
Two functions are overridden:
setContext.The override for
interopBroker extends your existing
interopBroker to initialize interop brokers and interop clients on your platform and the external platform. The
interopBroker override also connects your interop client's context groups to the matching context groups from the external broker. The
setContext extends the existing
setContext to send context updates to both platforms.
Due to the use of overrides, the implementation is straightforward:
- Clone or download the container starter repo from OpenFin's "Built on Openfin" GitHub organization.
- Navigate to
- Copy-and-paste the code from
provider.tsto the file that contains your platform's
setContextfunctions. Or, just copy the
provider.tsfile into your project.
It is literally a copy-and-paste of code.
provider.ts file contains this bit of code:
super(overrideProvider, overrideOpts, ...overrideArgs);
this.externalBroker = "EXTERNAL_PLATFORM_UUID"; // provide your platform UUID
this.externalClients = new Map();
this.overrideArgs = overrideArgs;
this.overrideArgs = [...this.overrideArgs, "connect-external"];
this.initializeBrokers().catch((error) => console.error(error));
Note that this solution will connect only two platforms. Connecting more than two platforms is a larger problem outside the scope of this solution.
If you would like to see a working sample that connects interop to two platforms, you can follow the step-by-step instructions in the setup-multi-platform-interop section of the Container-Starter project.
Updated 23 days ago