@openfin/core 27.71.21 → 27.71.23

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfin/core",
3
- "version": "27.71.21",
3
+ "version": "27.71.23",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./src/mock.js",
6
6
  "types": "./src/mock.d.ts",
@@ -15,6 +15,7 @@ export default class ChannelClient extends ChannelBase {
15
15
  constructor(routingInfo: RoutingInfo, wire: Transport, strategy: AnyStrategy);
16
16
  protected processAction: (action: string, payload: any, senderIdentity: ProviderIdentity | OpenFin.ClientIdentity) => Promise<any>;
17
17
  get providerIdentity(): ProviderIdentity;
18
+ getRTCConnection(): RTCPeerConnection;
18
19
  dispatch(action: string, payload?: any): Promise<any>;
19
20
  onDisconnection(listener: DisconnectionListener): void;
20
21
  disconnect(): Promise<void>;
@@ -49,6 +49,9 @@ class ChannelClient extends channel_1.ChannelBase {
49
49
  const protectedObj = __classPrivateFieldGet(this, _protectedObj);
50
50
  return protectedObj.providerIdentity;
51
51
  }
52
+ getRTCConnection() {
53
+ return __classPrivateFieldGet(this, _strategy).getRTCConnection(this.providerIdentity.channelId);
54
+ }
52
55
  async dispatch(action, payload) {
53
56
  if (__classPrivateFieldGet(this, _strategy).isEndpointConnected(this.providerIdentity.channelId)) {
54
57
  return __classPrivateFieldGet(this, _strategy).send(this.providerIdentity.channelId, action, payload);
@@ -10,6 +10,7 @@ export declare class ClassicStrategy implements ChannelStrategy<EndpointPayload>
10
10
  private providerIdentity;
11
11
  constructor(wire: Transport, messageReceiver: MessageReceiver, endpointId: string, // Provider endpointId is channelId
12
12
  providerIdentity: ProviderIdentity);
13
+ getRTCConnection(endpointId: string): RTCPeerConnection;
13
14
  onEndpointDisconnect(endpointId: string, listener: () => void): void;
14
15
  receive(listener: (action: string, payload: any, identity: OpenFin.ClientIdentity | OpenFin.ClientIdentityMultiRuntime | ProviderIdentity) => Promise<any>): void;
15
16
  send: (endpointId: string, action: string, payload: any) => Promise<any>;
@@ -57,6 +57,9 @@ class ClassicStrategy {
57
57
  };
58
58
  __classPrivateFieldSet(this, _wire, wire);
59
59
  }
60
+ getRTCConnection(endpointId) {
61
+ throw new Error("Not implemented");
62
+ }
60
63
  onEndpointDisconnect(endpointId, listener) {
61
64
  // Never fires for 'classic'.
62
65
  }
@@ -15,6 +15,7 @@ export default class CombinedStrategy<A, B> implements ChannelStrategy<OnlyIfCom
15
15
  addEndpoint(endpoint: string, payload: OnlyIfCompatible<A, B>): Promise<void>;
16
16
  receive(listener: (action: string, payload: any, identity: any) => Promise<any>): void;
17
17
  send(endpointId: string, action: string, payload: any): Promise<any>;
18
+ getRTCConnection(endpointId: string): RTCPeerConnection;
18
19
  close(): Promise<void>;
19
20
  }
20
21
  export {};
@@ -51,6 +51,18 @@ class CombinedStrategy {
51
51
  }
52
52
  return this.secondary.send(endpointId, action, payload);
53
53
  }
54
+ getRTCConnection(endpointId) {
55
+ let connection;
56
+ try {
57
+ if (this.primary.isEndpointConnected(endpointId)) {
58
+ connection = this.primary.getRTCConnection(endpointId);
59
+ }
60
+ }
61
+ catch (error) {
62
+ console.log("error getting rtcpeer from primary");
63
+ }
64
+ return connection !== null && connection !== void 0 ? connection : this.secondary.getRTCConnection(endpointId);
65
+ }
54
66
  async close() {
55
67
  await Promise.all([this.primary.close(), this.secondary.close()]);
56
68
  }
@@ -20,4 +20,5 @@ export declare class RTCEndpoint {
20
20
  send: (action: string, payload: any) => Promise<any>;
21
21
  close: () => void;
22
22
  get connected(): boolean;
23
+ get peerConnection(): RTCPeerConnection;
23
24
  }
@@ -130,6 +130,9 @@ class RTCEndpoint {
130
130
  get connected() {
131
131
  return this.rtc.rtcClient.connectionState === 'connected';
132
132
  }
133
+ get peerConnection() {
134
+ return this.rtc.rtcClient;
135
+ }
133
136
  }
134
137
  exports.RTCEndpoint = RTCEndpoint;
135
138
  _processAction = new WeakMap(), _disconnectListener = new WeakMap();
@@ -9,6 +9,7 @@ export interface RTCStrategyEndpointPayload {
9
9
  export declare class RTCStrategy implements ChannelStrategy<RTCStrategyEndpointPayload> {
10
10
  #private;
11
11
  onEndpointDisconnect(endpointId: string, listener: () => void): void;
12
+ getRTCConnection(endpointId: string): RTCPeerConnection;
12
13
  receive(listener: (action: string, payload: any, identity: OpenFin.ClientIdentity | OpenFin.ClientIdentityMultiRuntime | ProviderIdentity) => Promise<any>): void;
13
14
  send: (endpointId: string, action: string, payload: any) => Promise<any>;
14
15
  close: () => Promise<void>;
@@ -38,6 +38,13 @@ class RTCStrategy {
38
38
  onEndpointDisconnect(endpointId, listener) {
39
39
  this.getEndpointById(endpointId).onDisconnect(listener);
40
40
  }
41
+ getRTCConnection(endpointId) {
42
+ const endpoint = __classPrivateFieldGet(this, _rtcEndpointMap).get(endpointId);
43
+ if (!endpoint) {
44
+ throw new Error('Could not find WebRTC connection');
45
+ }
46
+ return endpoint.peerConnection;
47
+ }
41
48
  receive(listener) {
42
49
  if (__classPrivateFieldGet(this, _processAction)) {
43
50
  throw new Error('You have already set a listener for this RTC Strategy');
@@ -8,6 +8,7 @@ export interface ChannelStrategy<T extends unknown> {
8
8
  isEndpointConnected(endpointId: string): boolean;
9
9
  addEndpoint(endpointId: string, payload: T): void;
10
10
  isValidEndpointPayload(payload: unknown): payload is T;
11
+ getRTCConnection(endpointId: string): RTCPeerConnection;
11
12
  }
12
13
  export declare type EndpointIdentity = OpenFin.ClientIdentity | ProviderIdentity;
13
14
  export declare type EndpointPayload = {
@@ -13,6 +13,7 @@ export declare class ChannelProvider extends ChannelBase {
13
13
  get connections(): OpenFin.ClientIdentity[];
14
14
  static handleClientDisconnection(channel: ChannelProvider, payload: any): void;
15
15
  static setProviderRemoval(provider: ChannelProvider, remove: Function): void;
16
+ getRTCPeerConnection(endpointId: string): RTCPeerConnection;
16
17
  constructor(providerIdentity: ProviderIdentity, wire: Transport, strategy: AnyStrategy);
17
18
  dispatch(to: OpenFin.ClientIdentity | OpenFin.Identity, action: string, payload?: any): Promise<any>;
18
19
  protected processAction: (action: string, payload: any, senderIdentity: OpenFin.ClientIdentity | OpenFin.ClientIdentityMultiRuntime) => Promise<any>;
@@ -73,6 +73,9 @@ let ChannelProvider = /** @class */ (() => {
73
73
  static setProviderRemoval(provider, remove) {
74
74
  ChannelProvider.removalMap.set(provider, remove);
75
75
  }
76
+ getRTCPeerConnection(endpointId) {
77
+ return __classPrivateFieldGet(this, _strategy).getRTCConnection(endpointId);
78
+ }
76
79
  dispatch(to, action, payload) {
77
80
  var _a;
78
81
  const endpointId = (_a = to.endpointId) !== null && _a !== void 0 ? _a : this.getEndpointIdForOpenFinId(to, action);