1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-22 16:45:58 +01:00

Minor tweaks to error handling.

This commit is contained in:
Juliusz Chroboczek 2020-08-19 14:39:40 +02:00
parent 74cab72154
commit 8fbd16cc8c
2 changed files with 8 additions and 2 deletions

View file

@ -150,7 +150,7 @@ ServerConnection.prototype.close = function() {
* @param {message} m - the message to send. * @param {message} m - the message to send.
*/ */
ServerConnection.prototype.send = function(m) { ServerConnection.prototype.send = function(m) {
if(this.socket.readyState !== this.socket.OPEN) { if(!this.socket || this.socket.readyState !== this.socket.OPEN) {
// send on a closed connection doesn't throw // send on a closed connection doesn't throw
throw(new Error('Connection is not open')); throw(new Error('Connection is not open'));
} }

View file

@ -385,7 +385,11 @@ function stopUpMedia(c) {
*/ */
function delUpMedia(c) { function delUpMedia(c) {
stopUpMedia(c); stopUpMedia(c);
delMedia(c.id); try {
delMedia(c.id);
} catch(e) {
console.warn(e);
}
c.close(true); c.close(true);
delete(serverConnection.up[c.id]); delete(serverConnection.up[c.id]);
setButtonsVisibility() setButtonsVisibility()
@ -474,6 +478,8 @@ function setMedia(c, isUp) {
function delMedia(id) { function delMedia(id) {
let mediadiv = document.getElementById('peers'); let mediadiv = document.getElementById('peers');
let peer = document.getElementById('peer-' + id); let peer = document.getElementById('peer-' + id);
if(!peer)
throw new Error('Removing unknown media');
let media = document.getElementById('media-' + id); let media = document.getElementById('media-' + id);
media.srcObject = null; media.srcObject = null;