Handles the errors thrown by the data channel methods

This commit is contained in:
hristoterezov 2016-07-25 17:04:39 -05:00
parent 0a51ddd7ef
commit 8d162609e0
2 changed files with 40 additions and 15 deletions

View File

@ -14,6 +14,8 @@ import UIEvents from './service/UI/UIEvents';
import mediaDeviceHelper from './modules/devices/mediaDeviceHelper';
import {reportError} from './modules/util/helpers';
const ConnectionEvents = JitsiMeetJS.events.connection;
const ConnectionErrors = JitsiMeetJS.errors.connection;
@ -1153,9 +1155,13 @@ export default {
ConnectionQuality.addListener(CQEvents.LOCALSTATS_UPDATED,
(percent, stats) => {
APP.UI.updateLocalStats(percent, stats);
room.broadcastEndpointMessage({
type: this.commands.defaults.CONNECTION_QUALITY,
values: stats });
try {
room.broadcastEndpointMessage({
type: this.commands.defaults.CONNECTION_QUALITY,
values: stats });
} catch (e) {
reportError(e);
}
});
room.on(ConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
@ -1279,22 +1285,29 @@ export default {
});
APP.UI.addListener(UIEvents.SELECTED_ENDPOINT, (id) => {
room.selectParticipant(id);
try {
room.selectParticipant(id);
} catch (e) {
reportError(e);
}
});
APP.UI.addListener(UIEvents.PINNED_ENDPOINT, (smallVideo, isPinned) => {
var smallVideoId = smallVideo.getId();
if (smallVideo.getVideoType() === VIDEO_CONTAINER_TYPE
&& !APP.conference.isLocalId(smallVideoId))
if (isPinned)
room.pinParticipant(smallVideoId);
// When the library starts supporting multiple pins we would
// pass the isPinned parameter together with the identifier,
// but currently we send null to indicate that we unpin the
// last pinned.
else
room.pinParticipant(null);
try {
if (smallVideo.getVideoType() === VIDEO_CONTAINER_TYPE
&& !APP.conference.isLocalId(smallVideoId))
if (isPinned)
room.pinParticipant(smallVideoId);
// When the library starts supporting multiple pins we would
// pass the isPinned parameter together with the identifier,
// but currently we send null to indicate that we unpin the
// last pinned.
else
room.pinParticipant(null);
} catch (e) {
reportError(e);
}
});
APP.UI.addListener(

View File

@ -19,3 +19,15 @@ export function createDeferred () {
export function reload () {
window.location.reload();
}
/**
* Prints the error and reports it to the global error handler.
* @param e {Error} the error
* @param msg {string} [optional] the message printed in addition to the error
*/
export function reportError (e, msg = "") {
console.error(msg, e);
if(window.onerror)
window.onerror(msg, null, null,
null, e);
}