From 2fd950d14e2474cdf87f665bf5abdd13e702226c Mon Sep 17 00:00:00 2001 From: Christopher A Scherban Date: Wed, 17 Apr 2024 09:12:51 -0400 Subject: [PATCH] Allow options to be passed into connection checker (#1102) * Pass options into ConnectionCheck and allow implentation of Checker by external packages * remove private * Create angry-pens-suffer.md --------- Co-authored-by: lukasIO --- .changeset/angry-pens-suffer.md | 5 +++++ src/connectionHelper/ConnectionCheck.ts | 9 ++++++--- src/index.ts | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 .changeset/angry-pens-suffer.md diff --git a/.changeset/angry-pens-suffer.md b/.changeset/angry-pens-suffer.md new file mode 100644 index 0000000000..d9799e983a --- /dev/null +++ b/.changeset/angry-pens-suffer.md @@ -0,0 +1,5 @@ +--- +"livekit-client": patch +--- + +Allow options to be passed into connection checker diff --git a/src/connectionHelper/ConnectionCheck.ts b/src/connectionHelper/ConnectionCheck.ts index 891784ee17..bfada271a9 100644 --- a/src/connectionHelper/ConnectionCheck.ts +++ b/src/connectionHelper/ConnectionCheck.ts @@ -1,7 +1,7 @@ import { EventEmitter } from 'events'; import type TypedEmitter from 'typed-emitter'; +import type { CheckInfo, CheckerOptions, InstantiableCheck } from './checks/Checker'; import { CheckStatus, Checker } from './checks/Checker'; -import type { CheckInfo, InstantiableCheck } from './checks/Checker'; import { PublishAudioCheck } from './checks/publishAudio'; import { PublishVideoCheck } from './checks/publishVideo'; import { ReconnectCheck } from './checks/reconnect'; @@ -16,12 +16,15 @@ export class ConnectionCheck extends (EventEmitter as new () => TypedEmitter = new Map(); - constructor(url: string, token: string) { + constructor(url: string, token: string, options: CheckerOptions = {}) { super(); this.url = url; this.token = token; + this.options = options; } private getNextCheckId() { @@ -50,7 +53,7 @@ export class ConnectionCheck extends (EventEmitter as new () => TypedEmitter(check: InstantiableCheck) { const checkId = this.getNextCheckId(); - const test = new check(this.url, this.token); + const test = new check(this.url, this.token, this.options); const handleUpdate = (info: CheckInfo) => { this.updateCheck(checkId, info); }; diff --git a/src/index.ts b/src/index.ts index 616dcdd301..992aa3be29 100644 --- a/src/index.ts +++ b/src/index.ts @@ -32,6 +32,7 @@ import { import { getBrowser } from './utils/browserParser'; export * from './connectionHelper/ConnectionCheck'; +export * from './connectionHelper/checks/Checker'; export * from './e2ee'; export * from './options'; export * from './room/errors';