Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit f833aec

Browse files
authored
Add error event for publication and subscription. (#139)
1 parent a7829a2 commit f833aec

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

src/sdk/base/publication.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ export class PublicationSettings {
105105
* | Event Name | Argument Type | Fired when |
106106
* | ----------------| ---------------- | ---------------- |
107107
* | ended | Event | Publication is ended. |
108+
* | error | ErrorEvent | An error occurred on the publication. |
108109
* | mute | MuteEvent | Publication is muted. Client stopped sending audio and/or video data to remote endpoint. |
109110
* | unmute | MuteEvent | Publication is unmuted. Client continued sending audio and/or video data to remote endpoint. |
110111
*

src/sdk/conference/channel.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -483,12 +483,13 @@ export class ConferencePeerConnectionChannel extends EventDispatcher {
483483
return;
484484
}
485485

486-
Logger.debug('ICE connection state changed to '
487-
+ event.currentTarget.iceConnectionState);
488-
if (event.currentTarget.iceConnectionState === 'closed'
489-
|| event.currentTarget.iceConnectionState === 'failed') {
490-
this._rejectPromise(
491-
new ConferenceError('ICE connection failed or closed.'));
486+
Logger.debug('ICE connection state changed to ' +
487+
event.currentTarget.iceConnectionState);
488+
if (event.currentTarget.iceConnectionState === 'closed' ||
489+
event.currentTarget.iceConnectionState === 'failed') {
490+
if (event.currentTarget.iceConnectionState === 'failed') {
491+
this._handleError('ICE connection failed.');
492+
}
492493
// Fire ended event if publication or subscription exists.
493494
this._fireEndedEventOnPublicationOrSubscription();
494495
}
@@ -583,17 +584,20 @@ export class ConferencePeerConnectionChannel extends EventDispatcher {
583584
}
584585

585586
_errorHandler(errorMessage) {
587+
return this._handleError(errorMessage);
588+
}
589+
590+
_handleError(errorMessage){
591+
const error = new ConferenceError(errorMessage);
586592
const p = this._publishPromise || this._subscribePromise;
587593
if (p) {
588-
p.reject(new ConferenceError(errorMessage));
589-
return;
594+
return this._rejectPromise(error);
590595
}
591596
const dispatcher = this._publication || this._subscription;
592597
if (!dispatcher) {
593598
Logger.warning('Neither publication nor subscription is available.');
594599
return;
595600
}
596-
const error = new ConferenceError(errorMessage);
597601
const errorEvent = new ErrorEvent('error', {
598602
error: error,
599603
});

src/sdk/conference/subscription.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ export class SubscriptionUpdateOptions {
250250
* | Event Name | Argument Type | Fired when |
251251
* | ----------------| ---------------- | ---------------- |
252252
* | ended | Event | Subscription is ended. |
253+
* | error | ErrorEvent | An error occurred on the subscription. |
253254
* | mute | MuteEvent | Publication is muted. Remote side stopped sending audio and/or video data. |
254255
* | unmute | MuteEvent | Publication is unmuted. Remote side continued sending audio and/or video data. |
255256
*

0 commit comments

Comments
 (0)