From 641340944b86fd59a53cadff5636f0090d7fd413 Mon Sep 17 00:00:00 2001 From: "braveyao@webrtc.org" Date: Tue, 10 Sep 2013 17:37:16 +0000 Subject: [PATCH] Show the signaling state and ice connection state in AppRTC by hooking up the peerconnections .onsignalingstatechange and .oniceconnectionstatechange events. Hopefully this will increase the quality of the "it does not work" reports from users by giving them more information about what is going on under the hood. R=juberti@google.com Review URL: https://webrtc-codereview.appspot.com/2174004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@4718 4adac7df-926f-26a2-2b94-8c16560cd09d --- samples/js/apprtc/js/main.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/samples/js/apprtc/js/main.js b/samples/js/apprtc/js/main.js index bd05fd3ae..f6f0d09f2 100644 --- a/samples/js/apprtc/js/main.js +++ b/samples/js/apprtc/js/main.js @@ -143,6 +143,8 @@ function createPeerConnection() { } pc.onaddstream = onRemoteStreamAdded; pc.onremovestream = onRemoteStreamRemoved; + pc.onsignalingstatechange = onSignalingStateChanged; + pc.oniceconnectionstatechange = onIceConnectionStateChanged; } function maybeStart() { @@ -340,6 +342,14 @@ function onRemoteStreamRemoved(event) { console.log('Remote stream removed.'); } +function onSignalingStateChanged(event) { + updateInfoDiv(); +} + +function onIceConnectionStateChanged(event) { + updateInfoDiv(); +} + function onHangup() { console.log('Hanging up.'); transitionToDone(); @@ -428,6 +438,13 @@ function updateInfoDiv() { for (var type in gatheredIceCandidateTypes[endpoint]) contents += " " + type + "\n"; } + if (pc != null) { + contents += "Gathering: " + pc.iceGatheringState + "\n"; + contents += "\n"; + contents += "
PC State:\n";
+    contents += "Signaling: " + pc.signalingState + "\n";
+    contents += "ICE: " + pc.iceConnectionState + "\n";
+  }
   var div = getInfoDiv();
   div.innerHTML = contents + "
"; }