OpenFin FDC3 app development

OpenFin simplifies FDC3 application development by providing a built-in DesktopAgent (called the Interop Broker), automatically connecting applications to the Interop Broker, and providing built-in System Channel and App Channel management.

Here is a quick introduction to OpenFin's new paradigm for FDC3 support.

Support for FDC3 applications

In the past, FDC3 application developers had to create and connect to a DesktopAgent, manage channels, and perform other tasks to meet the FDC3 standard.

We simplify things for you

This is what the new, simplified FDC3 paradigm looks like:

  • Every Platform automatically comes with a DesktopAgent, which we call the Interop Broker. Application developers can simply use the APIs that are automatically available. You can read more about them in our FDC3 API reference documentation.
  • Every view in a platform automatically connects to the Interop Broker for you.
  • We take care of System Channel management for you, if you use OpenFin Workspace as your platform. Workspace comes with a color picker channel management system built into the UI. Your app only has to listen to incoming context messages and broadcast its own context messages.
    You can read the Introduction to Workspace or the Workspace Developer Quick Start for more information on OpenFin Workspace.
  • We take care of App Channel management for you as well, if you use OpenFin Workspace as your platform. Your platform applications can then communicate with each other on a channel name or channel names of your choosing.

The core APIs

As an application developer, you only need to use a few APIs if you use OpenFin Workspace. This applies whether you are using contexts, intents, or app channels.

The core APIs for contexts

Code example:

function handleIncomingContext(contextInfo) {
    const { type, id } = contextInfo;
    switch (type) {
        case 'fdc3.instrument':
            handleInstrumentContext(contextInfo);
            break;
        case 'fdc3.country':
            handleCountryContext(contextInfo);
            break;

        default:
            break;
    }
}

function handleInstrumentContext(contextInfo) {
    const { type, id } = contextInfo;
    console.log('contextInfo for instrument', contextInfo)
}

function handleCountryContext(contextInfo) {
    const { type, id } = contextInfo;
    console.log('contextInfo for country', contextInfo)
}

fdc3.addContextListener(handleIncomingContext);
  • fdc3.broadcast: Sends a context to all other members of the context group.

Code example:

setInstrumentContext = async (ticker) => {
    fdc3.broadcast({type: 'fdc3.instrument', id: {ticker}})
}

// The user clicks an instrument of interest. We want to set that Instrument context so that the rest of our workflow updates with information for that instrument
instrumentElement.on('click', (evt) => {
    setInstrumentContext(evt.ticker)
})

The core APIs for intents

Code example:

const contextHandler = (context) => {
    myViewChartListener(context);
};

const listener = fdc3.addIntentListener('ViewChart', contextHandler);

function myAppCloseSequence() {
    // to unsubscribe the handler, simply call:
    listener.unsubscribe();
}

Code example:

tickerElement.on('click', (element) => {
    const ticker = element.innerText;
    const context = { type: 'fdc3.instrument', id: { ticker } };

    fdc3.raiseIntent('ViewChart', context);
})

// Passing in a target app
tickerElement.on('click', (element) => {
    const ticker = element.innerText;
    const context = { type: 'fdc3.instrument', id: { ticker } };

    fdc3.raiseIntent('ViewChart', context, 'skype');

    // The shape of the intent that will then come in through InteropBroker.handleFiredIntent will be:
    {
        name: 'ViewChart',
        context: { type: 'fdc3.instrument', id: { ticker } },
        metadata: { target: 'skype' }
    }
})

The core APIs for App Channels


Did this page help you?