Skip to content

Commit

Permalink
fix: add callback for connecterror (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
dnimon committed Nov 17, 2023
1 parent aff73f0 commit 9324246
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/adapters/WHEPAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export class WHEPAdapter implements Adapter {
await this.initSdpExchange();
} catch (error) {
console.error((error as Error).toString());
this.onErrorHandler('connecterror');
}
}

Expand Down
8 changes: 7 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ enum Message {
NO_MEDIA = 'no-media',
MEDIA_RECOVERED = 'media-recovered',
PEER_CONNECTION_FAILED = 'peer-connection-failed',
INITIAL_CONNECTION_FAILED = 'initial-connection-failed'
INITIAL_CONNECTION_FAILED = 'initial-connection-failed',
CONNECT_ERROR = 'connect-error'
}

export interface MediaConstraints {
Expand Down Expand Up @@ -146,6 +147,11 @@ export class WebRTCPlayer extends EventEmitter {
this.videoElement.srcObject = null;
this.emit(Message.INITIAL_CONNECTION_FAILED);
break;
case 'connecterror':
this.peer && this.peer.close();
this.adapter.resetPeer(this.peer);
this.emit(Message.CONNECT_ERROR);
break;
}
}

Expand Down

0 comments on commit 9324246

Please sign in to comment.