From e84cc146ad0cbc41c14c0e1eb87d69eec6435a5f Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Mon, 6 Feb 2023 13:33:09 -0800 Subject: [PATCH] Cleanup JS console logs --- web/static/js/BareRTC.js | 58 ++++------------------------------------ 1 file changed, 5 insertions(+), 53 deletions(-) diff --git a/web/static/js/BareRTC.js b/web/static/js/BareRTC.js index d9c4193..5589b35 100644 --- a/web/static/js/BareRTC.js +++ b/web/static/js/BareRTC.js @@ -1,4 +1,4 @@ -console.log("BareRTC!"); +// console.log("BareRTC!"); // WebRTC configuration. const configuration = { @@ -212,7 +212,7 @@ const app = Vue.createApp({ return; } - console.debug("Send message: %s", this.message); + // console.debug("Send message: %s", this.message); this.ws.conn.send(JSON.stringify({ action: "message", channel: this.channel, @@ -273,7 +273,7 @@ const app = Vue.createApp({ onOpen(msg) { // Response for the opener to begin WebRTC connection. const secret = msg.openSecret; - console.log("OPEN: connect to %s with secret %s", msg.username, secret); + // console.log("OPEN: connect to %s with secret %s", msg.username, secret); // this.ChatClient(`onOpen called for ${msg.username}.`); this.startWebRTC(msg.username, true); @@ -281,7 +281,7 @@ const app = Vue.createApp({ onRing(msg) { // Message for the receiver to begin WebRTC connection. const secret = msg.openSecret; - console.log("RING: connection from %s with secret %s", msg.username, secret); + // console.log("RING: connection from %s with secret %s", msg.username, secret); this.ChatServer(`${msg.username} has opened your camera.`); this.startWebRTC(msg.username, false); @@ -347,7 +347,7 @@ const app = Vue.createApp({ // Dial the WebSocket connection. dial() { - console.log("Dialing WebSocket..."); + // console.log("Dialing WebSocket..."); const proto = location.protocol === 'https:' ? 'wss' : 'ws'; const conn = new WebSocket(`${proto}://${location.host}/ws`); @@ -377,7 +377,6 @@ const app = Vue.createApp({ }); conn.addEventListener("message", ev => { - console.log(ev); if (typeof ev.data !== "string") { console.error("unexpected message type", typeof ev.data); return; @@ -393,11 +392,9 @@ const app = Vue.createApp({ switch (msg.action) { case "who": - console.log("Got the Who List: %s", msg); this.onWho(msg); break; case "me": - console.log("Got a self-update: %s", msg); this.onMe(msg); break; case "message": @@ -434,7 +431,6 @@ const app = Vue.createApp({ }); break; case "ping": - console.debug("Received ping from server"); break; default: console.error("Unexpected action: %s", JSON.stringify(msg)); @@ -464,11 +460,7 @@ const app = Vue.createApp({ // 'onicecandidate' notifies us whenever an ICE agent needs to deliver a // message to the other peer through the signaling server. pc.onicecandidate = event => { - console.error("WebRTC OnICECandidate called!", event); - // this.ChatClient("On ICE Candidate called!"); if (event.candidate) { - // this.ChatClient(`Send ICE candidate: ${JSON.stringify(event.candidate)}`); - console.log("Sending candidate to websockets:", event.candidate); this.ws.conn.send(JSON.stringify({ action: "candidate", username: username, @@ -479,18 +471,13 @@ const app = Vue.createApp({ // If the user is offerer let the 'negotiationneeded' event create the offer. if (isOfferer) { - // this.ChatClient("We are the offerer - set up onNegotiationNeeded"); pc.onnegotiationneeded = () => { - console.error("WebRTC OnNegotiationNeeded called!"); - // this.ChatClient("Negotiation Needed, creating WebRTC offer."); pc.createOffer().then(this.localDescCreated(pc, username)).catch(this.ChatClient); }; } // When a remote stream arrives. pc.ontrack = event => { - // this.ChatServer("ON TRACK CALLED!!!"); - console.error("WebRTC OnTrack called!", event); const stream = event.streams[0]; // Do we already have it? @@ -502,9 +489,7 @@ const app = Vue.createApp({ window.requestAnimationFrame(() => { let $ref = document.getElementById(`videofeed-${username}`); - console.log("Video elem:", $ref); $ref.srcObject = stream; - // this.$refs[`videofeed-${username}`].srcObject = stream; }); // Inform them they are being watched. @@ -520,7 +505,6 @@ const app = Vue.createApp({ // this.ChatClient(`Sharing our video stream to ${username}.`); let stream = this.webcam.stream; stream.getTracks().forEach(track => { - console.error("Add stream track to WebRTC", stream, track); pc.addTrack(track, stream) }); } @@ -554,16 +538,12 @@ const app = Vue.createApp({ // Handle inbound WebRTC signaling messages proxied by the websocket. onCandidate(msg) { - console.error("onCandidate() called:", msg); if (this.WebRTC.pc[msg.username] == undefined) { - console.error("DID NOT FIND RTCPeerConnection for username:", msg.username); return; } let pc = this.WebRTC.pc[msg.username]; // Add the new ICE candidate. - console.log("Add ICE candidate: %s", msg.candidate); - // this.ChatClient(`Received an ICE candidate from ${msg.username}: ${JSON.stringify(msg.candidate)}`); pc.addIceCandidate( new RTCIceCandidate( msg.candidate, @@ -573,34 +553,17 @@ const app = Vue.createApp({ ); }, onSDP(msg) { - console.error("onSDP() called:", msg); if (this.WebRTC.pc[msg.username] == undefined) { - console.error("DID NOT FIND RTCPeerConnection for username:", msg.username); return; } let pc = this.WebRTC.pc[msg.username]; let message = msg.description; // Add the new ICE candidate. - console.log("Set description:", message); // this.ChatClient(`Received a Remote Description from ${msg.username}: ${JSON.stringify(msg.description)}.`); pc.setRemoteDescription(new RTCSessionDescription(message), () => { // When receiving an offer let's answer it. if (pc.remoteDescription.type === 'offer') { - console.error("Webcam:", this.webcam); - - // Add our local video tracks to the connection. - // if (this.webcam.active) { - // this.ChatClient(`Sharing our video stream to ${msg.username}.`); - // let stream = this.webcam.stream; - // stream.getTracks().forEach(track => { - // console.error("Add stream track to WebRTC", stream, track); - // pc.addTrack(track, stream) - // }); - // } - - // this.ChatClient(`setRemoteDescription callback. Offer recieved - sending answer. Cam active? ${this.webcam.active}`); - console.warn("Creating answer now"); pc.createAnswer().then(this.localDescCreated(pc, msg.username)).catch(this.ChatClient); } }, console.error); @@ -834,7 +797,6 @@ const app = Vue.createApp({ muteMe() { this.webcam.muted = !this.webcam.muted; this.webcam.stream.getAudioTracks().forEach(track => { - console.error("Set audio track enabled=%s", !this.webcam.muted, track); track.enabled = !this.webcam.muted; }); }, @@ -843,11 +805,9 @@ const app = Vue.createApp({ }, muteVideo(username) { this.WebRTC.muted[username] = !this.isMuted(username); - console.error("muteVideo(%s) is not muted=%s", username, this.WebRTC.muted[username]); // Find the