From f8f51eed3cfd5490cd6b68aed418de2f825b79f9 Mon Sep 17 00:00:00 2001 From: Christoph Guttandin Date: Fri, 24 Nov 2023 20:55:24 +0100 Subject: [PATCH] feat: handle array events --- src/factories/timing-provider-constructor.ts | 4 ++++ src/interfaces/array-event.ts | 8 ++++++++ src/interfaces/index.ts | 1 + src/types/incoming-signaling-event.ts | 4 ++-- 4 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 src/interfaces/array-event.ts diff --git a/src/factories/timing-provider-constructor.ts b/src/factories/timing-provider-constructor.ts index 62348ac3..82ffcddf 100644 --- a/src/factories/timing-provider-constructor.ts +++ b/src/factories/timing-provider-constructor.ts @@ -274,6 +274,10 @@ export const createTimingProviderConstructor = ( ), enforceOrder((event): event is IInitEvent => event.type === 'init'), concatMap((event) => { + if (event.type === 'array') { + return from(event.events); + } + if (event.type === 'init') { const { client: { id: clientId }, diff --git a/src/interfaces/array-event.ts b/src/interfaces/array-event.ts new file mode 100644 index 00000000..3f445fff --- /dev/null +++ b/src/interfaces/array-event.ts @@ -0,0 +1,8 @@ +import { INoticeEvent } from './notice-event'; +import { IRequestEvent } from './request-event'; + +export interface IArrayEvent { + events: (INoticeEvent | IRequestEvent)[]; + + type: 'array'; +} diff --git a/src/interfaces/index.ts b/src/interfaces/index.ts index dcee2a27..c07cd5f6 100644 --- a/src/interfaces/index.ts +++ b/src/interfaces/index.ts @@ -1,3 +1,4 @@ +export * from './array-event'; export * from './candidate-event'; export * from './check-event'; export * from './closure-event'; diff --git a/src/types/incoming-signaling-event.ts b/src/types/incoming-signaling-event.ts index 00843571..091c0c3d 100644 --- a/src/types/incoming-signaling-event.ts +++ b/src/types/incoming-signaling-event.ts @@ -1,4 +1,4 @@ -import { IClosureEvent, IInitEvent, ITerminationEvent } from '../interfaces'; +import { IArrayEvent, IClosureEvent, IInitEvent, ITerminationEvent } from '../interfaces'; import { TIncomingNegotiationEvent } from './incoming-negotiation-event'; -export type TIncomingSignalingEvent = IClosureEvent | TIncomingNegotiationEvent | IInitEvent | ITerminationEvent; +export type TIncomingSignalingEvent = IArrayEvent | IClosureEvent | TIncomingNegotiationEvent | IInitEvent | ITerminationEvent;