@openfin/core 28.71.16 → 28.71.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/OpenFin.d.ts CHANGED
@@ -1708,4 +1708,14 @@ declare namespace OpenFin {
1708
1708
  | 'navigateForward'
1709
1709
  | 'navigateBack'
1710
1710
  | 'print';
1711
+
1712
+ export type InteropBrokerDisconnectionEvent = {
1713
+ type: string;
1714
+ topic: string;
1715
+ brokerName: string;
1716
+ };
1717
+
1718
+ export type InteropClientOnDisconnectionListener = (
1719
+ InteropBrokerDisconnectionEvent: InteropBrokerDisconnectionEvent
1720
+ ) => any;
1711
1721
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfin/core",
3
- "version": "28.71.16",
3
+ "version": "28.71.17",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./src/mock.js",
6
6
  "types": "./src/mock.d.ts",
@@ -315,6 +315,13 @@ export declare class InteropBroker extends Base {
315
315
  * @experimental
316
316
  */
317
317
  handleFiredIntentForContext(contextForIntent: OpenFin.ContextForIntent, clientIdentity: OpenFin.ClientIdentity): Promise<unknown>;
318
+ /**
319
+ * Provides the identity of any Interop Client that disconnects from the Interop Broker. It is meant to be overriden.
320
+ * @param clientIdentity
321
+ * @return { Promise<void> }
322
+ * @tutorial interop.clientDisconnected
323
+ */
324
+ clientDisconnected(clientIdentity: OpenFin.ClientIdentity): Promise<void>;
318
325
  decorateSnapshot(snapshot: OpenFin.Snapshot): OpenFin.Snapshot;
319
326
  applySnapshot(snapshot: OpenFin.Snapshot, options: OpenFin.ApplySnapshotOptions): void;
320
327
  updateExistingClients(contextGroupStates: OpenFin.ContextGroupStates): void;
@@ -602,6 +602,17 @@ class InteropBroker extends base_1.Base {
602
602
  console.warn(warning);
603
603
  throw new Error(utils_1.BROKER_ERRORS.fireIntentForContext);
604
604
  }
605
+ /**
606
+ * Provides the identity of any Interop Client that disconnects from the Interop Broker. It is meant to be overriden.
607
+ * @param clientIdentity
608
+ * @return { Promise<void> }
609
+ * @tutorial interop.clientDisconnected
610
+ */
611
+ // eslint-disable-next-line class-methods-use-this
612
+ async clientDisconnected(clientIdentity) {
613
+ // This function is called in channel.onDisconnection.
614
+ // It is meant to be overridden to inform when an Interop Client has been disconnected.
615
+ }
605
616
  /*
606
617
  Snapshot APIs
607
618
  */
@@ -879,6 +890,7 @@ class InteropBroker extends base_1.Base {
879
890
  this.sessionContextGroupMap.forEach((sessionContextGroup) => {
880
891
  sessionContextGroup.onDisconnection(clientIdentity);
881
892
  });
893
+ this.clientDisconnected(clientIdentity);
882
894
  });
883
895
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
884
896
  // @ts-ignore
@@ -264,4 +264,12 @@ export declare class InteropClient extends Base {
264
264
  * @experimental
265
265
  */
266
266
  joinSessionContextGroup(sessionContextGroupId: string): Promise<OpenFin.SessionContextGroup>;
267
+ /**
268
+ * Register a listener that is called when the Interop Client has been disconnected from the Interop Broker.
269
+ * Only one listener per Interop Client can be set.
270
+ * @param listener
271
+ * @return { Promise<void> }
272
+ * @tutorial interop.onDisconnection
273
+ */
274
+ onDisconnection(listener: OpenFin.InteropClientOnDisconnectionListener): Promise<void>;
267
275
  }
@@ -433,6 +433,23 @@ class InteropClient extends base_1.Base {
433
433
  throw error;
434
434
  }
435
435
  }
436
+ /**
437
+ * Register a listener that is called when the Interop Client has been disconnected from the Interop Broker.
438
+ * Only one listener per Interop Client can be set.
439
+ * @param listener
440
+ * @return { Promise<void> }
441
+ * @tutorial interop.onDisconnection
442
+ */
443
+ async onDisconnection(listener) {
444
+ this.wire.sendAction('interop-client-add-ondisconnection-listener').catch((e) => {
445
+ // don't expose, analytics-only call
446
+ });
447
+ const client = await __classPrivateFieldGet(this, _clientPromise);
448
+ return client.onDisconnection((event) => {
449
+ const { uuid } = event;
450
+ listener({ type: 'interop-broker', topic: 'disconnected', brokerName: uuid });
451
+ });
452
+ }
436
453
  }
437
454
  exports.InteropClient = InteropClient;
438
455
  _clientPromise = new WeakMap(), _sessionContextGroups = new WeakMap();