Merge pull request #751 from jitsi/dc_send_throw

Handles the errors thrown by the data channel methods
This commit is contained in:
bgrozev 2016-07-26 09:34:06 -05:00 committed by GitHub
commit 330597182c
2 changed files with 34 additions and 10 deletions

View File

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

View File

@ -19,3 +19,15 @@ export function createDeferred () {
export function reload () { export function reload () {
window.location.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);
}