Skip to content

Commit

Permalink
Allow options to be passed into connection checker (#1102)
Browse files Browse the repository at this point in the history
* Pass options into ConnectionCheck and allow implentation of Checker by external packages

* remove private

* Create angry-pens-suffer.md

---------

Co-authored-by: lukasIO <[email protected]>
  • Loading branch information
cscherban and lukasIO authored Apr 17, 2024
1 parent 8acb1d9 commit 2fd950d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/angry-pens-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-client": patch
---

Allow options to be passed into connection checker
9 changes: 6 additions & 3 deletions src/connectionHelper/ConnectionCheck.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -16,12 +16,15 @@ export class ConnectionCheck extends (EventEmitter as new () => TypedEmitter<Con

url: string;

options: CheckerOptions = {};

private checkResults: Map<number, CheckInfo> = 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() {
Expand Down Expand Up @@ -50,7 +53,7 @@ export class ConnectionCheck extends (EventEmitter as new () => TypedEmitter<Con

async createAndRunCheck<T extends Checker>(check: InstantiableCheck<T>) {
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);
};
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 2fd950d

Please sign in to comment.