From 3231f4248aa04f090010df1772d60127766d56a1 Mon Sep 17 00:00:00 2001 From: Pontus Persson Date: Fri, 8 Dec 2017 15:29:45 +0100 Subject: [PATCH] Modularize datachannel options. --- client/config.js | 5 +++++ client/webrtc.js | 9 ++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/client/config.js b/client/config.js index 3e07031..0e2b35f 100644 --- a/client/config.js +++ b/client/config.js @@ -4,3 +4,8 @@ export const peerConnectionConfig = { {'urls': 'stun:stun.l.google.com:19302'}, ], }; + +export const dataChannelConfig = { + ordered: false, // do not guarantee order + maxRetransmitTime: 500, // in milliseconds +}; diff --git a/client/webrtc.js b/client/webrtc.js index a863fda..e3594ee 100755 --- a/client/webrtc.js +++ b/client/webrtc.js @@ -1,4 +1,4 @@ -import { peerConnectionConfig } from './config.js'; +import { dataChannelConfig, peerConnectionConfig } from './config.js'; var localVideo; var localStream; @@ -8,11 +8,6 @@ var uuid; var serverConnection; var dataChannel; -var dataChannelOptions = { - ordered: false, // do not guarantee order - maxRetransmitTime: 500, // in milliseconds -}; - function pageReady() { document.querySelector("button#start") .addEventListener("click", start); @@ -53,7 +48,7 @@ function start(isCaller) { dataChannel.channel.send('Hello there, I got your signal'); }); - dataChannel = peerConnection.createDataChannel("myLabel", dataChannelOptions); + dataChannel = peerConnection.createDataChannel("myLabel", dataChannelConfig); dataChannel.addEventListener('error', function (error) { console.log("Data Channel Error:", error); });