-
Notifications
You must be signed in to change notification settings - Fork 164
Expand file tree
/
Copy pathMessaging.ts
More file actions
61 lines (52 loc) · 1.58 KB
/
Messaging.ts
File metadata and controls
61 lines (52 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { AppIdentifier } from '@finos/fdc3-standard';
import { RegisterableListener } from './listeners/RegisterableListener.js';
import {
AppRequestMessage,
AgentResponseMessage,
WebConnectionProtocol6Goodbye,
} from '@finos/fdc3-schema/dist/generated/api/BrowserTypes.js';
export interface Messaging {
/**
* Creates UUIDs used in outgoing messages
*/
createUUID(): string;
/**
* Post an outgoing message
*/
post(message: AppRequestMessage | WebConnectionProtocol6Goodbye): Promise<void>;
/**
* Registers a listener for incoming messages.
*/
register(l: RegisterableListener): void;
/**
* Unregister a listener with the given id
* @param id
*/
unregister(id: string): void;
/** Create a metadata element to attach to outgoing messages. */
createMeta(): AppRequestMessage['meta'];
/**
* Waits for a specific matching message
*/
waitFor<X extends AgentResponseMessage>(
filter: (m: X) => boolean,
timeoutMs?: number,
timeoutErrorMessage?: string
): Promise<X>;
/**
* Sends a request message and waits for a response. If the response contains a payload.error, it is thrown.
* @param message The request message to send.
*/
exchange<X extends AgentResponseMessage>(
message: AppRequestMessage,
expectedTypeName: string,
timeoutMs: number
): Promise<X>;
/**
* App identification used to provide source information used in
* message meta elements, IntentResolution etc..
*/
getAppIdentifier(): AppIdentifier;
/** Disconnects the underlying message transport. */
disconnect(): Promise<void>;
}