From c684411cf3d2cd748caf669b6459c11e598af44a Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Wed, 11 Dec 2019 15:50:07 +0100 Subject: [PATCH] catch errors when sending messages --- src/y-webrtc.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/y-webrtc.js b/src/y-webrtc.js index 7027cfa..07ce609 100644 --- a/src/y-webrtc.js +++ b/src/y-webrtc.js @@ -104,7 +104,9 @@ const readPeerMessage = (peerConn, buf) => { */ const sendWebrtcConn = (webrtcConn, encoder) => { log('send message to ', logging.BOLD, webrtcConn.remotePeerId, logging.UNBOLD, logging.GREY, ' (', webrtcConn.room.name, ')', logging.UNCOLOR) - webrtcConn.peer.send(encoding.toUint8Array(encoder)) + try { + webrtcConn.peer.send(encoding.toUint8Array(encoder)) + } catch (e) {} } /** @@ -115,7 +117,9 @@ const broadcastWebrtcConn = (room, encoder) => { log('broadcast message in ', logging.BOLD, room.name, logging.UNBOLD) const m = encoding.toUint8Array(encoder) room.webrtcConns.forEach(conn => { - conn.peer.send(m) + try { + conn.peer.send(m) + } catch (e) {} }) }