Web-based interoperability
You can create web content that participates in Here Core interoperability workflows when loaded in a web browser. Such workflows include context sharing and intents, using the Here Core Interop, FDC3 and Channel APIs. This functionality is enabled by the Core Web package (published as Web Interop for v37 only).
The Core Web package allows web content that runs in a standard browser tab or a progressive web app (PWA) on a tablet to interact directly with other content in that browser tab or PWA. For example, a user could:
-
Select a contact from a view in their web browser.
-
Watch as the contact's portfolio appears in another view in that web browser tab through context sharing.
The Core Web package enables cross-site communication in a "platform-like" environment within a single web browser tab.
To accomplish this, Core Web requires the platform owner to host the following on the same domain:
-
The top-level app that embeds other content
-
The Web Broker server components described below
Any iframe
running under such a top-level app can connect to the page's Web Broker of the page and interoperate, regardless of origin.
There are some limitations to what Core Web is able to accomplish in a browser:
-
Core Web does not connect web pages that exist in separate native web browser tabs. Core Web cannot enable communication between native web browser tabs in a way that conflicts with web browsers' privacy sandboxes.
-
Core Web works with cross-site and cross-origin websites so long as the Web Broker and the top-level app exist in the same origin.
-
Examples of cross-site websites: example.com and ejemplo.com, or compare.com and contrast.com
-
Examples of cross-origin websites: docs.example.com, support.example.com
-
Here™ minimizes the differences between the interoperability APIs supported on the desktop and the web. In most cases, code that works with the desktop Interop APIs also works with Core Web, though some changes may be needed.
Core Web for content developers
If you are a developer who is building content applications which use the Here Core APIs, the default entry point of the Core Web package provides a connect
function. This is designed to complement the type definitions found in @openfin/core.
Install
Run the following command:
npm install @openfin/core-web -S
Core Web is framework agnostic; it is designed to work with any UI framework.
Connect to a Web Broker
An @openfin/core-web
Web Broker is a piece of hosted infrastructure that you can connect to from a web site in order to interact with other content connected to the same Web Broker. A Web Broker is responsible for deciding whether you can connect to it, and connecting you to other applications via the Here Core Interop and Channels APIs.
When you connect to a @openfin/core-web
broker with a specific URL, it returns a fin
connection.
Example: Basic connection setup
import { connect } from '@openfin/core-web';
const brokerUrl = 'http://example.com/web-broker';
(async () => {
// Connect to the Here Core Web Broker.
const fin = await connect({ options: { brokerUrl }});
// You may now use the `fin` object. In this case, use it to connect to a channel.
const channelClient = await fin.InterapplicationBus.Channel.connect('some channel name');
})();
Set a timeout
You can use the timeout
option (in milliseconds) to specify to abandon the connection after a set amount of time.
The example below shows how to set up a 30-second timeout.
Example: Set a timeout
// This connect call throws if a connection is not established within 30 seconds.
await connect({ options: { brokerUrl, timeout: 30000 }});
Set up an interop connection
You can configure an Interop connection to automatically set up an interop client. You can then access the client via the fin.me.interop
namespace.
You must specify a Provider ID. An example is shown below:
Example: Connect to an interop broker
// Specify an interopConfig with a specific provider ID to initialize the `fin.me.interop` client on connection.
const fin = await connect({ options: { brokerUrl, interopConfig: { providerId: 'PROVIDER_ID' }}});
// fin.me.interop is an InteropClient connected to the `PROVIDER_ID` InteropBroker.
fin.me.interop.addContextHandler((context) => console.log('received context'));
Specify an initial context group
By default, the Here Core Interop Client API does not select a context group. The following example illustrates setting up an initial context group during connection.
Example: Join a default context group
// Specify an interopConfig with a specific provider ID and a context group to initialize the `fin.me.interop` client on connection.
const fin = await connect({ options: { brokerUrl, interopConfig: { providerId: 'provider-id', currentContextGroup: 'red' }}});
// The fin.me.interop client adds a context handler which receives updates published on the `red` context group.
fin.me.interop.addContextHandler((context) => console.log('received context'));