sendrecv/js: Fix some null/undefined checks

This commit is contained in:
Nirbheek Chauhan 2018-04-01 01:52:46 +05:30
parent 669d234ebd
commit 9cc57d2dd1

View file

@ -59,7 +59,8 @@ function setError(text) {
function resetVideo() { function resetVideo() {
// Release the webcam and mic // Release the webcam and mic
local_stream_promise.then(stream => { stream.stop(); }); if (local_stream_promise)
local_stream_promise.then(stream => { stream.stop(); });
// Reset the video element and stop showing the last received frame // Reset the video element and stop showing the last received frame
var videoElement = getVideoElement(); var videoElement = getVideoElement();
@ -125,7 +126,7 @@ function onServerMessage(event) {
} }
// Incoming JSON signals the beginning of a call // Incoming JSON signals the beginning of a call
if (peer_connection == null) if (!peer_connection)
createCall(msg); createCall(msg);
if (msg.sdp != null) { if (msg.sdp != null) {
@ -141,7 +142,7 @@ function onServerMessage(event) {
function onServerClose(event) { function onServerClose(event) {
resetVideo(); resetVideo();
if (peer_connection != null) { if (peer_connection) {
peer_connection.close(); peer_connection.close();
peer_connection = null; peer_connection = null;
} }