Interface: DesktopAgent
A Desktop Agent is a desktop component (or aggregate of components) that serves as a launcher and message router (broker) for applications in its domain.
A Desktop Agent can be connected to one or more App Directories and will use directories for application identity and discovery. Typically, a Desktop Agent will contain the proprietary logic of a given platform, handling functionality like explicit application interop workflows where security, consistency, and implementation requirements are proprietary.
Methods
addContextListener
▸ addContextListener(handler
): Listener
Adds a listener for incoming context broadcast from the Desktop Agent.
deprecated
use addContextListener(null, handler)
instead of addContextListener(handler)
.
Parameters
Name | Type |
---|---|
handler | ContextHandler |
Returns
▸ addContextListener(contextType
, handler
): Listener
Adds a listener for the broadcast of a specific type of context object.
Parameters
Name | Type |
---|---|
contextType | null | string |
handler | ContextHandler |
Returns
addIntentListener
▸ addIntentListener(intent
, handler
): Listener
Adds a listener for incoming Intents from the Agent.
Parameters
Name | Type |
---|---|
intent | string |
handler | ContextHandler |
Returns
broadcast
▸ broadcast(context
): void
Publishes context to other apps on the desktop.
DesktopAgent implementations should ensure that context messages broadcast to a channel by an application joined to it should not be delivered back to that same application.
agent.broadcast(context);
Parameters
Name | Type |
---|---|
context | Context |
Returns
void
findIntent
▸ findIntent(intent
, context?
): Promise
<AppIntent
>
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 that registered it is returned. This can be used to raise the intent against a specific app.
If the resolution fails, the promise will return an Error
with a string from the ResolveError
enumeration.
// I know 'StartChat' exists as a concept, and want to know more about it ...
const appIntent = await agent.findIntent("StartChat");
// returns a single AppIntent:
// {
// intent: { name: "StartChat", displayName: "Chat" },
// apps: [{ name: "Skype" }, { name: "Symphony" }, { name: "Slack" }]
// }
// raise the intent against a particular app
await agent.raiseIntent(appIntent.intent.name, context, appIntent.apps[0].name);
Parameters
Name | Type |
---|---|
intent | string |
context? | Context |
Returns
Promise
<AppIntent
>
findIntentsByContext
▸ findIntentsByContext(context
): Promise
<AppIntent
[]>
Find all the avalable intents for a particular context.
findIntents 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 that registered it is returned, based on the context types the intents have registered.
If the resolution fails, the promise will return an Error
with a string from the ResolveError
enumeration.
// I have a context object, and I want to know what I can do with it, hence, I look for for intents...
const appIntents = await agent.findIntentsByContext(context);
// returns for example:
// [{
// intent: { name: "StartCall", displayName: "Call" },
// apps: [{ name: "Skype" }]
// },
// {
// intent: { name: "StartChat", displayName: "Chat" },
// apps: [{ name: "Skype" }, { name: "Symphony" }, { name: "Slack" }]
// }];
// select a particular intent to raise
const startChat = appIntents[1];
// target a particular app
const selectedApp = startChat.apps[0];
// raise the intent, passing the given context, targeting the app
await agent.raiseIntent(startChat.intent.name, context, selectedApp.name);
Parameters
Name | Type |
---|---|
context | Context |
Returns
Promise
<AppIntent
[]>
getCurrentChannel
▸ getCurrentChannel(): Promise
<null
| Channel
>
Returns the Channel
object for the current channel membership.
Returns null
if the app is not joined to a channel.
Returns
Promise
<null
| Channel
>
getInfo
▸ getInfo(): ImplementationMetadata
Retrieves information about the FDC3 Desktop Agent implementation, such as the implemented version of the FDC3 specification and the name of the implementation provider.
Returns
getOrCreateChannel
▸ getOrCreateChannel(channelId
): Promise
<Channel
>
Returns a channel with the given identity. Either stands up a new channel or returns an existing channel.
It is up to applications to manage how to share knowledge of these custom channels across windows and to manage channel ownership and lifecycle.
Error
with a string from the ChannelError
enumeration.
Parameters
Name | Type |
---|---|
channelId | string |
Returns
Promise
<Channel
>
getSystemChannels
▸ getSystemChannels(): Promise
<Channel
[]>
Retrieves a list of the System channels available for the app to join
Returns
Promise
<Channel
[]>
joinChannel
▸ joinChannel(channelId
): Promise
<void
>
Joins the app to the specified channel.
An app can only be joined to one channel at a time.
Rejects with error if the channel is unavailable or the join request is denied.
Error
with a string from the ChannelError
enumeration.
Parameters
Name | Type |
---|---|
channelId | string |
Returns
Promise
<void
>
leaveCurrentChannel
▸ leaveCurrentChannel(): Promise
<void
>
Removes the app from any channel membership.
Context broadcast and listening through the top-level fdc3.broadcast
and fdc3.addContextListener
will be
in a no-op when the app is not on a channel.
Returns
Promise
<void
>
open
▸ open(app
, context?
): Promise
<void
>
Launches an app by target, which can be optionally a string like a name, or an AppMetadata object.
If a Context object is passed in, this object will be provided to the opened application via a contextListener. The Context argument is functionally equivalent to opening the target app with no context and broadcasting the context directly to it.
If opening errors, it returns an Error
with a string from the OpenError
enumeration.
//no context and string as target
agent.open('myApp');
//no context and AppMetadata object as target
agent.open({name: 'myApp', title: 'The title for the application myApp.', description: '...'});
//with context
agent.open('myApp', context);
Parameters
Name | Type |
---|---|
app | TargetApp |
context? | Context |
Returns
Promise
<void
>
raiseIntent
▸ raiseIntent(intent
, context
, app?
): Promise
<IntentResolution
>
Raises an intent to the desktop agent to resolve.
//Find apps to resolve an intent to start a chat with a given contact
const appIntent = await fdc3.findIntent("StartChat", context);
//use the returned AppIntent object to target one of the returned chat apps with the context
await fdc3.raiseIntent("StartChat", context, appIntent.apps[0].name);
//or use one of the AppMetadata objects returned in the AppIntent object's 'apps' array
await fdc3.raiseIntent("StartChat", context, appMetadata);
Parameters
Name | Type |
---|---|
intent | string |
context | Context |
app? | TargetApp |
Returns
Promise
<IntentResolution
>
raiseIntentForContext
▸ raiseIntentForContext(context
, app?
): Promise
<IntentResolution
>
Raises a context to the desktop agent to resolve with one of the possible Intents for that context.
await fdc3.raiseIntentForContext(context);
Parameters
Name | Type |
---|---|
context | Context |
app? | TargetApp |
Returns
Promise
<IntentResolution
>