mirror of https://github.com/OpenVidu/openvidu.git
openvidu-browser: ExceptionEvent
parent
4219c6dbc7
commit
ff8b51dbf1
|
@ -22,6 +22,7 @@ import { RemoteConnectionOptions } from '../OpenViduInternal/Interfaces/Private/
|
||||||
import { InboundStreamOptions } from '../OpenViduInternal/Interfaces/Private/InboundStreamOptions';
|
import { InboundStreamOptions } from '../OpenViduInternal/Interfaces/Private/InboundStreamOptions';
|
||||||
import { StreamOptionsServer } from '../OpenViduInternal/Interfaces/Private/StreamOptionsServer';
|
import { StreamOptionsServer } from '../OpenViduInternal/Interfaces/Private/StreamOptionsServer';
|
||||||
import { OpenViduLogger } from '../OpenViduInternal/Logger/OpenViduLogger';
|
import { OpenViduLogger } from '../OpenViduInternal/Logger/OpenViduLogger';
|
||||||
|
import { ExceptionEvent, ExceptionEventName } from '../OpenViduInternal/Events/ExceptionEvent';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hidden
|
* @hidden
|
||||||
|
@ -142,8 +143,8 @@ export class Connection {
|
||||||
sdpMLineIndex: candidate.sdpMLineIndex
|
sdpMLineIndex: candidate.sdpMLineIndex
|
||||||
}, (error, response) => {
|
}, (error, response) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
logger.error('Error sending ICE candidate: '
|
logger.error('Error sending ICE candidate: ' + JSON.stringify(error));
|
||||||
+ JSON.stringify(error));
|
this.session.emitEvent('exception', [new ExceptionEvent(this.session, ExceptionEventName.ICE_CANDIDATE_ERROR, this.session, "There was an unexpected error on the server-side processing an ICE candidate generated and sent by the client-side", error)]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,7 @@ let platform: PlatformUtils;
|
||||||
* - networkQualityLevelChanged ([[NetworkQualityLevelChangedEvent]])
|
* - networkQualityLevelChanged ([[NetworkQualityLevelChangedEvent]])
|
||||||
* - reconnecting
|
* - reconnecting
|
||||||
* - reconnected
|
* - reconnected
|
||||||
|
* - exception ([[ExceptionEvent]])
|
||||||
*/
|
*/
|
||||||
export class Session extends EventDispatcher {
|
export class Session extends EventDispatcher {
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,9 @@ import { StreamManager } from './StreamManager';
|
||||||
import { Subscriber } from './Subscriber';
|
import { Subscriber } from './Subscriber';
|
||||||
import { InboundStreamOptions } from '../OpenViduInternal/Interfaces/Private/InboundStreamOptions';
|
import { InboundStreamOptions } from '../OpenViduInternal/Interfaces/Private/InboundStreamOptions';
|
||||||
import { OutboundStreamOptions } from '../OpenViduInternal/Interfaces/Private/OutboundStreamOptions';
|
import { OutboundStreamOptions } from '../OpenViduInternal/Interfaces/Private/OutboundStreamOptions';
|
||||||
import { WebRtcPeer, WebRtcPeerSendonly, WebRtcPeerRecvonly, WebRtcPeerSendrecv } from '../OpenViduInternal/WebRtcPeer/WebRtcPeer';
|
import { WebRtcPeer, WebRtcPeerSendonly, WebRtcPeerRecvonly, WebRtcPeerSendrecv, WebRtcPeerConfiguration } from '../OpenViduInternal/WebRtcPeer/WebRtcPeer';
|
||||||
import { WebRtcStats } from '../OpenViduInternal/WebRtcStats/WebRtcStats';
|
import { WebRtcStats } from '../OpenViduInternal/WebRtcStats/WebRtcStats';
|
||||||
|
import { ExceptionEvent, ExceptionEventName } from '../OpenViduInternal/Events/ExceptionEvent';
|
||||||
import { PublisherSpeakingEvent } from '../OpenViduInternal/Events/PublisherSpeakingEvent';
|
import { PublisherSpeakingEvent } from '../OpenViduInternal/Events/PublisherSpeakingEvent';
|
||||||
import { StreamManagerEvent } from '../OpenViduInternal/Events/StreamManagerEvent';
|
import { StreamManagerEvent } from '../OpenViduInternal/Events/StreamManagerEvent';
|
||||||
import { StreamPropertyChangedEvent } from '../OpenViduInternal/Events/StreamPropertyChangedEvent';
|
import { StreamPropertyChangedEvent } from '../OpenViduInternal/Events/StreamPropertyChangedEvent';
|
||||||
|
@ -805,10 +806,11 @@ export class Stream {
|
||||||
video: this.isSendVideo()
|
video: this.isSendVideo()
|
||||||
};
|
};
|
||||||
|
|
||||||
const options = {
|
const options: WebRtcPeerConfiguration = {
|
||||||
mediaStream: this.mediaStream,
|
mediaStream: this.mediaStream,
|
||||||
mediaConstraints: userMediaConstraints,
|
mediaConstraints: userMediaConstraints,
|
||||||
onicecandidate: this.connection.sendIceCandidate.bind(this.connection),
|
onicecandidate: this.connection.sendIceCandidate.bind(this.connection),
|
||||||
|
onexception: (exceptionName: ExceptionEventName, message: string, data?: any) => { this.session.emitEvent('exception', [new ExceptionEvent(this.session, exceptionName, this, message, data)]) },
|
||||||
iceServers: this.getIceServersConf(),
|
iceServers: this.getIceServersConf(),
|
||||||
simulcast: false
|
simulcast: false
|
||||||
};
|
};
|
||||||
|
@ -937,6 +939,7 @@ export class Stream {
|
||||||
offerConstraints);
|
offerConstraints);
|
||||||
const options = {
|
const options = {
|
||||||
onicecandidate: this.connection.sendIceCandidate.bind(this.connection),
|
onicecandidate: this.connection.sendIceCandidate.bind(this.connection),
|
||||||
|
onexception: (exceptionName: ExceptionEventName, message: string, data?: any) => { this.session.emitEvent('exception', [new ExceptionEvent(this.session, exceptionName, this, message, data)]) },
|
||||||
mediaConstraints: offerConstraints,
|
mediaConstraints: offerConstraints,
|
||||||
iceServers: this.getIceServersConf(),
|
iceServers: this.getIceServersConf(),
|
||||||
simulcast: false
|
simulcast: false
|
||||||
|
|
|
@ -102,12 +102,13 @@ export enum OpenViduErrorName {
|
||||||
OPENVIDU_PERMISSION_DENIED = 'OPENVIDU_PERMISSION_DENIED',
|
OPENVIDU_PERMISSION_DENIED = 'OPENVIDU_PERMISSION_DENIED',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _Not in use yet_
|
* There is no connection to the Session. This error will be thrown when any method requiring a connection to
|
||||||
|
* openvidu-server is called before successfully calling method [[Session.connect]]
|
||||||
*/
|
*/
|
||||||
OPENVIDU_NOT_CONNECTED = 'OPENVIDU_NOT_CONNECTED',
|
OPENVIDU_NOT_CONNECTED = 'OPENVIDU_NOT_CONNECTED',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _Not in use yet_
|
* Generic error
|
||||||
*/
|
*/
|
||||||
GENERIC_ERROR = 'GENERIC_ERROR'
|
GENERIC_ERROR = 'GENERIC_ERROR'
|
||||||
}
|
}
|
||||||
|
@ -117,7 +118,14 @@ export enum OpenViduErrorName {
|
||||||
*/
|
*/
|
||||||
export class OpenViduError {
|
export class OpenViduError {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uniquely identifying name of the error
|
||||||
|
*/
|
||||||
name: OpenViduErrorName;
|
name: OpenViduErrorName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Full description of the error
|
||||||
|
*/
|
||||||
message: string;
|
message: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
/*
|
||||||
|
* (C) Copyright 2017-2020 OpenVidu (https://openvidu.io)
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Session } from '../../OpenVidu/Session';
|
||||||
|
import { Stream } from '../../OpenVidu/Stream';
|
||||||
|
import { Event } from './Event';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines property [[ExceptionEvent.name]]
|
||||||
|
*/
|
||||||
|
export enum ExceptionEventName {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* There was an unexpected error on the server-side processing an ICE candidate generated and sent by the client-side.
|
||||||
|
*
|
||||||
|
* [[ExceptionEvent]] objects with this [[ExceptionEvent.name]] will have as [[ExceptionEvent.origin]] property a [[Session]] object.
|
||||||
|
*/
|
||||||
|
ICE_CANDIDATE_ERROR = 'ICE_CANDIDATE_ERROR',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The [ICE connection state](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/iceConnectionState)
|
||||||
|
* of an [RTCPeerConnection](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection) reached `failed` status.
|
||||||
|
*
|
||||||
|
* [[ExceptionEvent]] objects with this [[ExceptionEvent.name]] will have as [[ExceptionEvent.origin]] property a [[Stream]] object.
|
||||||
|
*/
|
||||||
|
ICE_CONNECTION_FAILED = 'ICE_CONNECTION_FAILED'
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines event `exception` dispatched by [[Session]] object.
|
||||||
|
*
|
||||||
|
* This event acts as a global handler for asynchronous errors that may be triggered for multiple reasons and from multiple origins.
|
||||||
|
*/
|
||||||
|
export class ExceptionEvent extends Event {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the exception
|
||||||
|
*/
|
||||||
|
name: ExceptionEventName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Object affected by the exception. Depending on the [[ExceptionEvent.name]] property:
|
||||||
|
* - [[Session]]: `ICE_CANDIDATE_ERROR`
|
||||||
|
* - [[Stream]]: `ICE_CONNECTION_FAILED`
|
||||||
|
*/
|
||||||
|
origin: Session | Stream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Informative description of the exception
|
||||||
|
*/
|
||||||
|
message: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Any extra information associated to the exception
|
||||||
|
*/
|
||||||
|
data?: any;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hidden
|
||||||
|
*/
|
||||||
|
constructor(session: Session, name: ExceptionEventName, origin: Session | Stream, message: string, data?: any) {
|
||||||
|
super(false, session, 'exception');
|
||||||
|
this.name = name;
|
||||||
|
this.origin = origin;
|
||||||
|
this.message = message;
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hidden
|
||||||
|
*/
|
||||||
|
// tslint:disable-next-line:no-empty
|
||||||
|
callDefaultBehavior() { }
|
||||||
|
|
||||||
|
}
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
import freeice = require('freeice');
|
import freeice = require('freeice');
|
||||||
import uuid = require('uuid');
|
import uuid = require('uuid');
|
||||||
|
import { ExceptionEventName } from '../Events/ExceptionEvent';
|
||||||
import { OpenViduLogger } from '../Logger/OpenViduLogger';
|
import { OpenViduLogger } from '../Logger/OpenViduLogger';
|
||||||
import { PlatformUtils } from '../Utils/Platform';
|
import { PlatformUtils } from '../Utils/Platform';
|
||||||
|
|
||||||
|
@ -37,6 +38,7 @@ export interface WebRtcPeerConfiguration {
|
||||||
};
|
};
|
||||||
simulcast: boolean;
|
simulcast: boolean;
|
||||||
onicecandidate: (event: RTCIceCandidate) => void;
|
onicecandidate: (event: RTCIceCandidate) => void;
|
||||||
|
onexception: (exceptionName: ExceptionEventName, message: string, data?: any) => void;
|
||||||
iceServers: RTCIceServer[] | undefined;
|
iceServers: RTCIceServer[] | undefined;
|
||||||
mediaStream?: MediaStream;
|
mediaStream?: MediaStream;
|
||||||
mode?: 'sendonly' | 'recvonly' | 'sendrecv';
|
mode?: 'sendonly' | 'recvonly' | 'sendrecv';
|
||||||
|
@ -322,7 +324,9 @@ export class WebRtcPeer {
|
||||||
logger.warn('IceConnectionState of RTCPeerConnection ' + this.id + ' (' + otherId + ') change to "disconnected". Possible network disconnection');
|
logger.warn('IceConnectionState of RTCPeerConnection ' + this.id + ' (' + otherId + ') change to "disconnected". Possible network disconnection');
|
||||||
break;
|
break;
|
||||||
case 'failed':
|
case 'failed':
|
||||||
logger.error('IceConnectionState of RTCPeerConnection ' + this.id + ' (' + otherId + ') to "failed"');
|
const msg = 'IceConnectionState of RTCPeerConnection ' + this.id + ' (' + otherId + ') to "failed"';
|
||||||
|
logger.error(msg);
|
||||||
|
this.configuration.onexception(ExceptionEventName.ICE_CONNECTION_FAILED, msg);
|
||||||
break;
|
break;
|
||||||
case 'closed':
|
case 'closed':
|
||||||
logger.log('IceConnectionState of RTCPeerConnection ' + this.id + ' (' + otherId + ') change to "closed"');
|
logger.log('IceConnectionState of RTCPeerConnection ' + this.id + ' (' + otherId + ') change to "closed"');
|
||||||
|
|
Loading…
Reference in New Issue