From 44c1e3ad8fd1e594cceebb36a97e3b126b7d6188 Mon Sep 17 00:00:00 2001 From: jordan lavatai Date: Wed, 5 Jul 2017 10:12:23 -0700 Subject: [PATCH] now we trigger data channel after setting up events! --- client.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/client.js b/client.js index 1f62625..956971a 100644 --- a/client.js +++ b/client.js @@ -123,15 +123,6 @@ function pollServerForICECandidate(cpc, url, pubKey) { getPublicKey().then((cpk) => { console.log('Client: Create and send offer') const cpc = new RTCPeerConnection(conf) - /* Start data channel */ - dataChannel = cpc.createDataChannel("sendChannel"); - dataChannel.onmessage = (msg) => { - console.log(msg.data) - } - dataChannel.onopen = () => { - dataChannel.send(`Hi from the Client`) - } - cpc.oniceconnectionstatechange = () => { console.log('iceConnectionState = ' + cpc.iceConnectionState) @@ -174,4 +165,13 @@ getPublicKey().then((cpk) => { console.log('error in sdp handshake: ' + err) }) } + /* Start data channel */ + dataChannel = cpc.createDataChannel("sendChannel"); + dataChannel.onmessage = (msg) => { + console.log(msg.data) + } + dataChannel.onopen = () => { + dataChannel.send(`Hi from the Client`) + } + }) -- 2.18.0