AboutSupportDeveloper GuideVersion 36.122.80.11

https://developers.openfin.co/of-docs/docs/enable-color-linking

The Interop Broker is responsible for keeping track of the Interop state of the Platform, and for directing messages to the proper locations.

Remarks

This class contains some types related to FDC3 that are specific to OpenFin. OpenFin's FDC3 support is forward- and backward-compatible. Standard types for FDC3 do not appear in OpenFin’s API documentation, to avoid duplication.


There are 2 ways to inject custom functionality into the Interop Broker:

1. Configuration

At the moment, you can configure the default context groups for the Interop Broker without having to override it. To do so, include the interopBrokerConfiguration contextGroups option in your platform options in your manifest. This is the preferred method.

{
"runtime": {
"arguments": "--v=1 --inspect",
"version": "alpha-v19"
},
"platform": {
"uuid": "platform_customization_local",
"applicationIcon": "https://openfin.github.io/golden-prototype/favicon.ico",
"autoShow": false,
"providerUrl": "http://localhost:5555/provider.html",
"interopBrokerConfiguration": {
"contextGroups": [
{
"id": "green",
"displayMetadata": {
"color": "#00CC88",
"name": "green"
}
},
{
"id": "purple",
"displayMetadata": {
"color": "#8C61FF",
"name": "purple"
}
},
]
}
}
}

By default the Interop Broker logs all actions to the console. You can disable this by using the logging option in interopBrokerConfiguration:

{
"runtime": {
"arguments": "--v=1 --inspect",
"version": "alpha-v19"
},
"platform": {
"uuid": "platform_customization_local",
"applicationIcon": "https://openfin.github.io/golden-prototype/favicon.ico",
"autoShow": false,
"providerUrl": "http://localhost:5555/provider.html",
"interopBrokerConfiguration": {
"logging": {
"beforeAction": {
"enabled": false
},
"afterAction": {
"enabled": false
}
}
}
}
}

2. Overriding

Similarly to how Platform Overriding works, you can override functions in the Interop Broker in fin.Platform.init. An example of that is shown below. Overriding isConnectionAuthorized and isActionAuthorized will allow you to control allowed connections and allowed actions.

However, if there is custom functionality you wish to include in the Interop Broker, please let us know. We would like to provide better configuration options so that you don't have to continually maintain your own override code.

fin.Platform.init({
overrideCallback: async (Provider) => {
class Override extends Provider {
async getSnapshot() {
console.log('before getSnapshot')
const snapshot = await super.getSnapshot();
console.log('after getSnapshot')
return snapshot;
}

async applySnapshot({ snapshot, options }) {
console.log('before applySnapshot')
const originalPromise = super.applySnapshot({ snapshot, options });
console.log('after applySnapshot')

return originalPromise;
}
};
return new Override();
},
interopOverride: async (InteropBroker) => {
class Override extends InteropBroker {
async joinContextGroup(channelName = 'default', target) {
console.log('before super joinContextGroup')
super.joinContextGroup(channelName, target);
console.log('after super joinContextGroup')
}
}

return new Override();
}
});

Hierarchy

  • Base
    • InteropBroker

Accessors

  • get me(): Identity
  • Provides access to the OpenFin representation of the current code context (usually a document such as a View or Window), as well as to the current Interop context.

    Useful for debugging in the devtools console, where this will intelligently type itself based on the context in which the devtools panel was opened.

    Returns Identity

Methods

  • Helper function for InteropBroker.joinContextGroup. Does the work of actually adding the client to the Context Group. Used by Platform Windows.

    Parameters

    • addClientToContextGroupOptions: {
          contextGroupId: string;
      }

      Contains the contextGroupId

      • contextGroupId: string
    • clientIdentity: ClientIdentity

      Identity of the client sender.

    Returns Promise<void>

  • Provides the identity of any Interop Client that disconnects from the Interop Broker. It is meant to be overriden.

    Parameters

    Returns Promise<void>

    Example

    fin.Platform.init({
    interopOverride: async (InteropBroker) => {
    class Override extends InteropBroker {
    async clientDisconnected(clientIdentity) {
    const { uuid, name } = clientIdentity;
    console.log(`Client with identity ${uuid}/${name} has been disconnected`);
    }
    }
    return new Override();
    }
    });
  • Parameters

    • __namedParameters: {
          contextType: undefined | string;
          handlerId: string;
      }
      • contextType: undefined | string
      • handlerId: string
    • clientIdentity: ClientIdentity

    Returns void

  • Responsible for resolving the fdc3.findInstances call. Must be overridden

    Parameters

    • app: AppIdentifier

      AppIdentifier that was passed to fdc3.findInstances

    • clientIdentity: ClientIdentity

      Identity of the Client making the request.

    Returns Promise<unknown>

  • Responsible for resolving the fdc3.getAppMetadata call. Must be overridden

    Parameters

    • app: AppIdentifier

      AppIdentifier that was passed to fdc3.getAppMetadata

    • clientIdentity: ClientIdentity

      Identity of the Client making the request.

    Returns Promise<unknown>

  • Responsible for resolving fdc3.getInfo for FDC3 2.0 Would need to return the optionalFeatures and appMetadata for the ImplementationMetadata. Must be overridden.

    Parameters

    • payload: {
          fdc3Version: string;
      }
      • fdc3Version: string
    • clientIdentity: ClientIdentity

    Returns Promise<unknown>

  • Responsible for resolving an fdc3.open call. Must be overridden.

    Parameters

    • fdc3OpenOptions: {
          app: TargetApp | AppIdentifier;
          context: Context;
      }

      fdc3.open options

      • app: TargetApp | AppIdentifier
      • context: Context
    • clientIdentity: ClientIdentity

      Identity of the Client making the request.

    Returns Promise<void | AppIdentifier>

  • Returns an array of info for each Interop Client connected to the Interop Broker.

    FDC3 2.0: Use the endpointId in the ClientInfo as the instanceId when generating an AppIdentifier.

    Returns Promise<ClientInfo[]>

    Remarks

    FDC3 2.0 Note: When needing an instanceId to generate an AppIdentifier use this call to get the endpointId and use it as the instanceId. In the Example below we override handleFiredIntent and then call super.getAllClientInfo to generate the AppIdentifier for the IntentResolution.

    Example

    // FDC3 2.0 Example:
    fin.Platform.init({
    interopOverride: async (InteropBroker, ...args) => {
    class Override extends InteropBroker {
    async handleFiredIntent(intent) {
    super.setIntentTarget(intent, { uuid: 'platform-uuid', name: 'intent-view' });
    const platform = fin.Platform.getCurrentSync();
    const win = fin.Window.wrapSync({ name: 'foo', uuid: 'platform-uuid' });
    const createdView = await platform.createView({ url: 'http://openfin.co', name: 'intent-view' }, win.identity);

    const allClientInfo = await super.getAllClientInfo();

    const infoForTarget = allClientInfo.find((clientInfo) => {
    return clientInfo.uuid === 'platform-uuid' && clientInfo.name === 'intent-view';
    });

    const source = {
    appId: 'intent-view',
    instanceId: infoForTarget.endpointId
    }

    return {
    source,
    intent: intent.name
    }

    }
    }
    return new Override(...args);
    }
    });
  • Gets all clients for a context group.

    Parameters

    • getAllClientsInContextGroupOptions: {
          contextGroupId: string;
      }

      Contains contextGroupId, the context group you wish to get clients for.

      • contextGroupId: string

    Returns ClientIdentity[]

    Remarks

    This is primarily used for platform windows. Views within a platform should not have to use this API. Returns the Interop-Broker-defined context groups available for an entity to join.

  • Returns the Interop-Broker-defined context groups available for an entity to join. Because this function is used in the rest of the Interop Broker to fetch the Context Groups, overriding this allows you to customize the Context Groups for the Interop Broker. However, we recommend customizing the context groups through configuration instead. Used by Platform Windows.

    Returns readonly ContextGroupInfo[]

  • Get current context for a client subscribed to a Context Group.

    Parameters

    • getCurrentContextOptions: {
          contextType: string;
      }
      • contextType: string
    • clientIdentity: ClientIdentity

      Identity of the client sender.

    Returns undefined | Context

    Remarks

    It takes an optional Context Type argument and returns the last context of that type.

  • Gets display info for a context group

    Parameters

    • getInfoForContextGroupOptions: {
          contextGroupId: string;
      }

      Contains contextGroupId, the context group you wish to get display info for.

      • contextGroupId: string

    Returns undefined | ContextGroupInfo

    Remarks

    Used by Platform Windows.

  • Responsible for launching of applications that can handle a given intent, and delegation of intents to those applications. Must be overridden.

    Parameters

    • intent: Intent<IntentMetadata<any>>

      The combination of an action and a context that is passed to an application for resolution.

    • clientIdentity: Identity & {
          endpointId: string;
          isLocalEndpointId: boolean;
      } & {
          entityType: EntityType;
      }

      Identity of the Client making the request.

    Returns Promise<unknown>

    Remarks

    To make this call FDC3-Compliant it would need to return an IntentResolution.

    interface IntentResolution {
    source: TargetApp;
    // deprecated, not assignable from intent listeners
    data?: object;
    version: string;
    }

    More information on the IntentResolution type can be found in the FDC3 documentation.

    Example

    // override call so we set intent target and create view that will handle it
    fin.Platform.init({
    interopOverride: async (InteropBroker) => {
    class Override extends InteropBroker {
    async handleFiredIntent(intent) {
    super.setIntentTarget(intent, { uuid: 'platform-uuid', name: 'intent-view' });
    const platform = fin.Platform.getCurrentSync();
    const win = fin.Window.wrapSync({ name: 'foo', uuid: 'platform-uuid' });
    const createdView = await platform.createView({ url: 'http://openfin.co', name: 'intent-view' }, win.identity);
    }
    }
    return new Override();
    }
    });
  • Responsible for resolving an Intent based on a specific Context. Must be overridden.

    Parameters

    • contextForIntent: ContextForIntent<any>

      Data passed between entities and applications.

    • clientIdentity: Identity & {
          endpointId: string;
          isLocalEndpointId: boolean;
      } & {
          entityType: EntityType;
      }

      Identity of the Client making the request.

    Returns Promise<unknown>

    Remarks

    Whenever InteropClient.fireIntentForContext is called this function will fire. The contextForIntent argument gives you access to the context that will be resolved to an intent. It also can optionally contain any metadata relevant to resolving it, like a specific app the client wants the context to be handled by. The clientIdentity is the identity of the client that made the call.

    To make this call FDC3-Compliant it would need to return an IntentResolution:

    // {
    // intent: { name: "StartChat", displayName: "Chat" },
    // apps: [{ name: "Skype" }, { name: "Symphony" }, { name: "Slack" }]
    // }

    More information on the IntentResolution type can be found in the FDC3 documentation.

    Example

    fin.Platform.init({
    interopOverride: async (InteropBroker) => {
    class Override extends InteropBroker {
    async handleFiredIntentForContext(contextForIntent, clientIdentity) {
    // Your code goes here.
    }
    }
    return new Override();
    }
    });
  • Responsible for returning information on a particular Intent.

    Parameters

    Returns Promise<unknown>

    Remarks

    Whenever InteropClient.getInfoForIntent is called this function will fire. The options argument gives you access to the intent name and any optional context that was passed and clientIdentity is the identity of the client that made the call. Ideally here you would fetch the info for the intent and return it with the shape that the InteropClient.getInfoForIntent call is expecting.

    To make this call FDC3-Compliant it would need to return an App Intent:

    // {
    // intent: { name: "StartChat", displayName: "Chat" },
    // apps: [{ name: "Skype" }, { name: "Symphony" }, { name: "Slack" }]
    // }

    More information on the AppIntent type can be found in the FDC3 documentation.

    Example

    fin.Platform.init({
    interopOverride: async (InteropBroker) => {
    class Override extends InteropBroker {
    async handleInfoForIntent(options, clientIdentity) {
    // Your code goes here.
    }
    }
    return new Override();
    }
    });
  • Responsible for returning information on which Intents are meant to handle a specific Context. Must be overridden.

    Parameters

    Returns Promise<unknown>

    Remarks

    Responsible for returning information on which Intents are meant to handle a specific Context. Must be overridden.

    Whenever InteropClient.getInfoForIntentsByContext is called this function will fire. The context argument gives you access to the context that the client wants information on and clientIdentity is the identity of the client that made the call. Ideally here you would fetch the info for any intent that can handle and return it with the shape that the InteropClient.getInfoForIntentsByContext call is expecting.

    To make this call FDC3-Compliant it would need to return an array of AppIntents:

    // [{
    // intent: { name: "StartCall", displayName: "Call" },
    // apps: [{ name: "Skype" }]
    // },
    // {
    // intent: { name: "StartChat", displayName: "Chat" },
    // apps: [{ name: "Skype" }, { name: "Symphony" }, { name: "Slack" }]
    // }];

    More information on the AppIntent type can be found in the FDC3 documentation.

    Example

    fin.Platform.init({
    interopOverride: async (InteropBroker) => {
    class Override extends InteropBroker {
    async handleInfoForIntentsByContext(context, clientIdentity) {
    // Your code goes here.
    }
    }
    return new Override();
    }
    });
  • Parameters

    • __namedParameters: {
          sessionContextGroupId: string;
      }
      • sessionContextGroupId: string
    • clientIdentity: ClientIdentity

    Returns {
        hasConflict: boolean;
    }

    • hasConflict: boolean
  • Parameters

    Returns Promise<void>

  • This function is called by the Interop Broker whenever a Context handler would fire. For FDC3 2.0 you would need to override this function and add the contextMetadata as part of the Context object. Then would you need to call super.invokeContextHandler passing it this new Context object along with the clientIdentity and handlerId

    Parameters

    Returns Promise<void>

    Example

    fin.Platform.init({
    interopOverride: async (InteropBroker) => {
    class Override extends InteropBroker {
    async invokeContextHandler(clientIdentity, handlerId, context) {
    return super.invokeContextHandler(clientIdentity, handlerId, {
    ...context,
    contextMetadata: {
    source: {
    appId: 'openfin-app',
    instanceId: '3D54D456D9HT0'
    }
    }
    });
    }
    }
    return new Override();
    }
    });
  • This function is called by the Interop Broker whenever an Intent handler would fire. For FDC3 2.0 you would need to override this function and add the contextMetadata as part of the Context object inside the Intent object. Then would you need to call super.invokeIntentHandler passing it this new Intent object along with the clientIdentity and handlerId

    Parameters

    Returns Promise<void>

    Example

    fin.Platform.init({
    interopOverride: async (InteropBroker) => {
    class Override extends InteropBroker {
    async invokeIntentHandler(clientIdentity, handlerId, context) {
    const { context } = intent;
    return super.invokeIntentHandler(clientIdentity, handlerId, {
    ...intent,
    context: {
    ...context,
    contextMetadata: {
    source: {
    appId: 'openfin-app',
    instanceId: '3D54D456D9HT0'
    }
    }
    }
    });
    }
    }
    return new Override();
    }
    });
  • Called before every action to check if this entity should be allowed to take the action. Return false to prevent the action

    Parameters

    • _action: string

      the string action to authorize in camel case

    • _payload: any

      the data being sent for this action

    • _identity: ClientIdentity

      the connection attempting to dispatch this action

    Returns boolean | Promise<boolean>

  • Can be used to completely prevent a connection. Return false to prevent connections. Allows all connections by default.

    Parameters

    • _id: Identity

      the identity tryinc to connect

    • Optional _connectionPayload: any

      optional payload to use in custom implementations, will be undefined by default

    Returns boolean | Promise<boolean>

  • Join all connections at the given identity (or just one if endpointId provided) to context group contextGroupId. If no target is specified, it adds the sender to the context group. joinContextGroup is responsible for checking connections at the incoming identity. It calls InteropBroker.addClientToContextGroup to actually group the client. Used by Platform Windows.

    Parameters

    • joinContextGroupOptions: {
          contextGroupId: string;
          target?: Identity | ClientIdentity;
      }

      Id of the Context Group and identity of the entity to join to the group.

    • senderIdentity: ClientIdentity

      Identity of the client sender.

    Returns Promise<void>

  • Parameters

    Returns void

  • Helper function for InteropBroker.removeFromContextGroup. Does the work of actually removing the client from the Context Group. Used by Platform Windows.

    Parameters

    Returns Promise<void>

  • Parameters

    • __namedParameters: {
          handlerId: string;
      }
      • handlerId: string
    • clientIdentity: ClientIdentity

    Returns void

  • Removes the specified target from a context group. If no target is specified, it removes the sender from their context group. removeFromContextGroup is responsible for checking connections at the incoming identity.

    Parameters

    • removeFromContextGroupOptions: {
          target: Identity;
      }

      Contains the target identity to remove.

    • senderIdentity: ClientIdentity

      Identity of the client sender.

    Returns Promise<void>

    Remarks

    It calls InteropBroker.removeClientFromContextGroup to actually ungroup the client. Used by Platform Windows.

  • Sets a context for the context group of the incoming current entity.

    Parameters

    • setContextOptions: {
          context: Context;
      }

      New context to set.

    • clientIdentity: ClientIdentity

      Identity of the client sender.

    Returns void

  • Sets a context for the context group.

    Parameters

    • setContextOptions: {
          context: Context;
      }

      New context to set.

    • contextGroupId: string

      Context group id.

    Returns void

  • Should be called in InteropBroker.handleFiredIntent. While handleFiredIntent is responsible for launching applications, setIntentTarget is used to tell the InteropBroker which application should receive the intent when it is ready.

    Parameters

    • intent: Intent<IntentMetadata<any>>

      The combination of an action and a context that is passed to an application for resolution.

    • target: Identity

      Identity of the target that will handle the intent.

    Returns Promise<void>

  • Parameters

    Returns void

  • Parameters

    Returns {
        isValid: true;
    } | {
        isValid: false;
        reason: string;
    }

  • Parameters

    • contextType: string
    • registeredContextType: undefined | string

    Returns boolean