Skip to content

Commit

Permalink
fix: uncaught exception and more debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
birme committed Jul 5, 2023
1 parent 61535ad commit 1f6ccd5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/adapters/Adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ export interface Adapter {
enableDebug(): void;
getPeer(): RTCPeerConnection | undefined;
resetPeer(newPeer: RTCPeerConnection): void;
connect(opts?: AdapterConnectOptions): void;
connect(opts?: AdapterConnectOptions): Promise<void>;
}
11 changes: 10 additions & 1 deletion src/adapters/WHEPAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ export class WHEPAdapter implements Adapter {
}

async connect(opts?: AdapterConnectOptions) {

Check warning on line 49 in src/adapters/WHEPAdapter.ts

View workflow job for this annotation

GitHub Actions / lint

'opts' is defined but never used
await this.initSdpExchange();
try {
await this.initSdpExchange();
} catch (error) {
console.error((error as Error).toString());
}
}

private async initSdpExchange() {
Expand Down Expand Up @@ -132,6 +136,7 @@ export class WHEPAdapter implements Adapter {

private async requestOffer() {
if (this.whepType === WHEPType.Server) {
this.log(`Requesting offer from: ${this.channelUrl.href}`);
const response = await fetch(this.channelUrl.href, {
method: 'POST',
headers: {
Expand All @@ -154,7 +159,11 @@ export class WHEPAdapter implements Adapter {
}
this.log('WHEP Resource', this.resource);
const offer = await response.text();
this.log('Received offer', offer);
return offer;
} else {
const serverMessage = await response.text();
throw new Error(serverMessage);
}
}
}
Expand Down

0 comments on commit 1f6ccd5

Please sign in to comment.