Listener type alias, generic type that can be used to refer any context or intent listener.
Adds a listener for incoming context broadcasts from the desktop agent.
To unsubscribe, use the returned ContextListener.
The handler function to call when we receive a broadcast context.
Event that is fired whenever a window changes from one channel to another. This captures events from all channels (including the default channel).
See also ChannelBase.addEventListener, for subscribing to events of a particular context channel.
The event type.
The handler to call when the event is fired.
Adds a listener for incoming intents from the Agent.
If the handler function returns a defined value, this value will be returned to the caller of raiseIntent in
the data
property of the IntentResolution object. If the value returned by the handler is a Promise, this
will be resolved before passing to the raiseIntent caller. If multiple handlers are registered by a target
application for a given intent, the fist defined return value to be returned and resolved (if a Promise) will be used.
To unsubscribe, use the returned IntentListener.
The name of the intent to listen for.
The handler to call when we get sent an intent.
Publishes context to other apps on the desktop. Any apps using addContextListener will receive this.
agent.broadcast(context);
Only windows in the same channel as the broadcasting window will receive the context. All windows will initially be in the same channel (referred to as the default channel). See ContextChannels for more details.
Note that windows do not receive their own broadcasts. If the window calling broadcast
has also added one or more
context listeners, then those listeners will not fire as a result of this broadcast.
The context to broadcast.
Find out more information about a particular intent by passing its name, and optionally its context.
findIntent
is effectively granting programmatic access to the desktop agent's resolver.
A promise resolving to the intent, its metadata and metadata about the apps registered to handle it is returned.
This can be used to raise the intent against a specific app.
For example, I know 'StartChat'
exists as a concept, and want to know more about it.
const appIntent = await agent.findIntent("StartChat");
This returns a single AppIntent (some fields omitted for brevity, see Application for full list of apps
fields):
{
intent: { name: "StartChat", displayName: "Chat" },
apps: [{ name: "Skype" }, { name: "Symphony" }, { name: "Slack" }]
}
We can then raise the intent against a particular app
await agent.raiseIntent(appIntent.intent.name, context, appIntent.apps[0].name);
The intent name to find.
An optional context to send to find the intent.
Find all the available intents for a particular context.
findIntentsByContext
is effectively granting programmatic access to the desktop agent's resolver.
A promise resolving to all the intents, their metadata and metadata about the apps registered to handle it is
returned, based on the context export types the intents have registered.
An empty array will be returned if there are no available intents for the given context.
For example, I have a context object and I want to know what I can do with it, so I look for intents...
const appIntents = await agent.findIntentsByContext(context);
This returns an array of AppIntent objects such as the following (some fields omitted for brevity, see
Application for full list of apps
fields):
[
{
intent: { name: "StartCall", displayName: "Call" },
apps: [{ name: "Skype" }]
},
{
intent: { name: "StartChat", displayName: "Chat" },
apps: [{ name: "Skype" }, { name: "Symphony" }, { name: "Slack" }]
}
]
We could now use this by taking one of the intents, and raising it.
// Select a particular intent to raise
const selectedIntent = appIntents[1];
// Raise the intent, passing the given context, letting the user select which app to use
await agent.raiseIntent(selectedIntent.intent.name, context);
// Raise the intent, passing the given context, targeting a particular app
const selectedApp = selectedIntent.apps[0];
await agent.raiseIntent(selectedIntent.intent.name, context, selectedApp.name);
Returned intents must support this context.
Launches/links to an app by name. The application will be started if it is not already running.
If a Context object is passed in, this object will be provided to the opened application via a ContextListener.
If opening errors, it returns an FDC3Error with a string from the ApplicationError export enumeration.
// No context
agent.open('myApp');
// With context
agent.open('myApp', context);
The AppName to launch.
A context to pass to the app post-launch.
Raises an intent to the desktop agent to resolve. Intents can be either targeted or non-targeted, determined by the
presence or absense of the target
argument. For non-targeted intents, the service will search the directory and
any running applications to find an application that can handle the given intent and context. If there are multiple
such applications, the end user will be asked to select which application they wish to use.
If the application isn't already running, it will be started by the service. The intent data will then be passed to the target application's intent listener. The promise returned by this function resolves when the service has confirmed that the target application has been started its intent listener has completed successfully.
The returned IntentResolution object indicates which application handled the intent (if the intent is a targeted
intent, this will always be the value passed as target
), and contains the data returned by the target applications
intent listener (if any).
// Raise an intent to start a chat with a given contact
const intentR = await agent.raiseIntent("StartChat", context);
// Use the IntentResolution object to target the same chat app with a new context
agent.raiseIntent("StartChat", newContext, intentR.source);
The intent name to raise.
The context that will be sent with this intent.
An optional AppName to send the intent to.
Unsubscribes from a particular event.
Has no effect if eventType
isn't a valid event, or listener
isn't a handler registered against eventType
.
The type of the event to remove.
The handler previously passed into addEventListener.