|
|
@@ -246,7 +246,21 @@ DataChannels.prototype._some = function (callback, thisArg) {
|
|
246
|
246
|
DataChannels.prototype.send = function (jsonObject) {
|
|
247
|
247
|
this._some(function (dataChannel) {
|
|
248
|
248
|
if (dataChannel.readyState == 'open') {
|
|
249
|
|
- dataChannel.send(JSON.stringify(jsonObject));
|
|
|
249
|
+ try {
|
|
|
250
|
+ // Can throw NetworkError and InvalidStateError. We
|
|
|
251
|
+ // shouldn't be experiencing InvalidStateError. But NetworkError
|
|
|
252
|
+ // is easily reproducable when start leaving the conference.
|
|
|
253
|
+ // I cannot reproduce it in any other use cases and for this one
|
|
|
254
|
+ // we can safely ignore the error and just report it to the
|
|
|
255
|
+ // global error handler. If we notice this error during the
|
|
|
256
|
+ // conference maybe it's better to throw it to the user of the
|
|
|
257
|
+ // library in order to notify the caller of the method for
|
|
|
258
|
+ // the failure.
|
|
|
259
|
+ dataChannel.send(JSON.stringify(jsonObject));
|
|
|
260
|
+ } catch (error) {
|
|
|
261
|
+ GlobalOnErrorHandler.callErrorHandler(error);
|
|
|
262
|
+ logger.error("Cannot send ", jsonObject, ". Error: ", error);
|
|
|
263
|
+ }
|
|
250
|
264
|
return true;
|
|
251
|
265
|
}
|
|
252
|
266
|
});
|