I'm currently attempting to work through this webRTC example and have encountered an issue that appears to be minor in nature... The if statement consistently fails to return true, despite the fact that the console message indicates that the property is present within the JSON.
function gotMessageFromServer(msg) {
// Is there a parsing problem? Assuming msg is already parsed.
// var signal = JSON.parse(msg);
var signal = msg;
console.log(msg);
console.log(msg["sdp"]);
console.log(typeof(msg));
if (signal.sdp) {
// Why is signal.sdp false?
}
Console Output:
{"sdp":{"type":"offer","sdp":"v=0\r\no=mozilla...THIS_IS_SDPARTA-45.0 2382924134299995518 0 IN IP4 0.0.0.0\r\ns=-\r\nt=0 0\r\na=sendrecv\r\na=fingerprint:sha-256 21:44:49:DD:C0:D9:CF:B6:EE:BB:69:FA:A6:65:F1:63:D1:E1:31:A0:6B:EE:A1:08:E4:36:47:B3:21:A3:3B:16\r\na=group:BUNDLE sdparta_0 sdparta_1\r\na=ice-options:trickle\r\na=msid-semantic:WMS *\r\nm=audio 9 UDP/TLS/RTP/SAVPF 109 9 0 8\r\nc=IN IP4 0.0.0.0\r\na=recvonly\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=ice-pwd:10d93ec1c51773af4e04dc11ade88d5e\r\na=ice-ufrag:54ca9275\r\na=mid:sdparta_0\r\na=rtcp-mux\r\na=rtpmap:109 opus/48000/2\r\na=rtpmap:9 G722/8000/1\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=setup:actpass\r\na=ssrc:232522377 cname:{bb5e63da-1ee9-4fc0-bb49-c96c58194b37}\r\nm=video 9 UDP/TLS/RTP/SAVPF 120 126 97\r\nc=IN IP4 0.0.0.0\r\na=recvonly\r\na=fmtp:120 max-fs=12288;max-fr=60\r\na=fmtp:126 profile-level-id=42e01f;level-asymmetry-allowed=1;packetization-mode=1\r\na=fmtp:97 profile-level-id=42e01f;level-asymmetry-allowed=1\r\na=ice-pwd:10d93ec1c51773af4e04dc11ade88d5e\r\na=ice-ufrag:54ca9275\r\na=mid:sdparta_1\r\na=rtcp-fb:120 nack\r\na=rtcp-fb:120 nack pli\r\na=rtcp-fb:120 ccm fir\r\na=rtcp-fb:126 nack\r\na=rtcp-fb:126 nack pli\r\na=rtcp-fb:126 ccm fir\r\na=rtcp-fb:97 nack\r\na=rtcp-fb:97 nack pli\r\na=rtcp-fb:97 ccm fir\r\na=rtcp-mux\r\na=rtpmap:120 VP8/90000\r\na=rtpmap:126 H264/90000\r\na=rtpmap:97 H264/90000\r\na=setup:actpass\r\na=ssrc:1196553112 cname:{bb5e63da-1ee9-4fc0-bb49-c96c58194b37}\r\n"},"uuid":"280a6161-5837-4d40-7752-a9e3d6688421"}
undefined
object