Cross-platform interop

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.

Solution

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.

Overrides

Two functions are overridden: interopBroker, and 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.

How to implement

Due to the use of overrides, the implementation is straightforward:

  1. Clone or download the container starter repo from OpenFin's "Built on Openfin" GitHub organization.
  2. Navigate to container-starter\how-to\use-interop\setup-multi-platform-interop\client\src
  3. Copy-and-paste the code from provider.ts to the file that contains your platform's interopBroker and setContext functions. Or, just copy the provider.ts file into your project.

It is literally a copy-and-paste of code.

Almost.

The 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));
    }

Caveats

Note that this solution will connect only two platforms. Connecting more than two platforms is a larger problem outside the scope of this solution.

More help

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.

See also

Interoperability overview