android, desktop: reduce browser call logs, check Worker availability directly (#3256)
This commit is contained in:
parent
f026a38a75
commit
795c54343a
@ -84,10 +84,8 @@ const processCommand = (function () {
|
||||
if (delay)
|
||||
clearTimeout(delay);
|
||||
resolved = true;
|
||||
console.log("LALAL resolveIceCandidates", JSON.stringify(candidates));
|
||||
//const ipv6Elem = candidates.find((item) => item.candidate.includes("raddr ::"))
|
||||
//candidates = ipv6Elem != undefined ? candidates.filter((elem) => elem == ipv6Elem) : candidates
|
||||
//console.log("LALAL resolveIceCandidates2", JSON.stringify(candidates))
|
||||
// console.log("resolveIceCandidates", JSON.stringify(candidates))
|
||||
console.log("resolveIceCandidates");
|
||||
const iceCandidates = serialize(candidates);
|
||||
candidates = [];
|
||||
resolve(iceCandidates);
|
||||
@ -95,7 +93,8 @@ const processCommand = (function () {
|
||||
function sendIceCandidates() {
|
||||
if (candidates.length === 0)
|
||||
return;
|
||||
console.log("LALAL sendIceCandidates", JSON.stringify(candidates));
|
||||
// console.log("sendIceCandidates", JSON.stringify(candidates))
|
||||
console.log("sendIceCandidates");
|
||||
const iceCandidates = serialize(candidates);
|
||||
candidates = [];
|
||||
sendMessageToNative({ resp: { type: "ice", iceCandidates } });
|
||||
@ -217,7 +216,7 @@ const processCommand = (function () {
|
||||
iceCandidates: await activeCall.iceCandidates,
|
||||
capabilities: { encryption },
|
||||
};
|
||||
console.log("LALALs", JSON.stringify(resp));
|
||||
// console.log("offer response", JSON.stringify(resp))
|
||||
break;
|
||||
}
|
||||
case "offer":
|
||||
@ -233,7 +232,7 @@ const processCommand = (function () {
|
||||
const { media, aesKey, iceServers, relay } = command;
|
||||
activeCall = await initializeCall(getCallConfig(!!aesKey, iceServers, relay), media, aesKey);
|
||||
const pc = activeCall.connection;
|
||||
console.log("LALALo", JSON.stringify(remoteIceCandidates));
|
||||
// console.log("offer remoteIceCandidates", JSON.stringify(remoteIceCandidates))
|
||||
await pc.setRemoteDescription(new RTCSessionDescription(offer));
|
||||
const answer = await pc.createAnswer();
|
||||
await pc.setLocalDescription(answer);
|
||||
@ -245,7 +244,7 @@ const processCommand = (function () {
|
||||
iceCandidates: await activeCall.iceCandidates,
|
||||
};
|
||||
}
|
||||
console.log("LALALo", JSON.stringify(resp));
|
||||
// console.log("answer response", JSON.stringify(resp))
|
||||
break;
|
||||
case "answer":
|
||||
if (!pc) {
|
||||
@ -260,7 +259,7 @@ const processCommand = (function () {
|
||||
else {
|
||||
const answer = parse(command.answer);
|
||||
const remoteIceCandidates = parse(command.iceCandidates);
|
||||
console.log("LALALa", JSON.stringify(remoteIceCandidates));
|
||||
// console.log("answer remoteIceCandidates", JSON.stringify(remoteIceCandidates))
|
||||
await pc.setRemoteDescription(new RTCSessionDescription(answer));
|
||||
addIceCandidates(pc, remoteIceCandidates);
|
||||
resp = { type: "ok" };
|
||||
@ -333,7 +332,7 @@ const processCommand = (function () {
|
||||
function addIceCandidates(conn, iceCandidates) {
|
||||
for (const c of iceCandidates) {
|
||||
conn.addIceCandidate(new RTCIceCandidate(c));
|
||||
console.log("LALAL addIceCandidates", JSON.stringify(c));
|
||||
// console.log("addIceCandidates", JSON.stringify(c))
|
||||
}
|
||||
}
|
||||
async function setupMediaStreams(call) {
|
||||
@ -356,8 +355,8 @@ const processCommand = (function () {
|
||||
if (useWorker && !call.worker) {
|
||||
const workerCode = `const callCrypto = (${callCryptoFunction.toString()})(); (${workerFunction.toString()})()`;
|
||||
call.worker = new Worker(URL.createObjectURL(new Blob([workerCode], { type: "text/javascript" })));
|
||||
call.worker.onerror = ({ error, filename, lineno, message }) => console.log(JSON.stringify({ error, filename, lineno, message }));
|
||||
call.worker.onmessage = ({ data }) => console.log(JSON.stringify({ message: data }));
|
||||
call.worker.onerror = ({ error, filename, lineno, message }) => console.log({ error, filename, lineno, message });
|
||||
// call.worker.onmessage = ({data}) => console.log(JSON.stringify({message: data}))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
"use strict";
|
||||
// Override defaults to enable worker on Chrome and Safari
|
||||
useWorker = window.safari !== undefined || navigator.userAgent.indexOf("Chrome") != -1;
|
||||
useWorker = typeof window.Worker !== "undefined";
|
||||
// Create WebSocket connection.
|
||||
const socket = new WebSocket(`ws://${location.host}`);
|
||||
socket.addEventListener("open", (_event) => {
|
||||
console.log("Opened socket");
|
||||
sendMessageToNative = (msg) => {
|
||||
console.log("Message to server: ", msg);
|
||||
console.log("Message to server");
|
||||
socket.send(JSON.stringify(msg));
|
||||
};
|
||||
});
|
||||
@ -14,7 +14,7 @@ socket.addEventListener("message", (event) => {
|
||||
const parsed = JSON.parse(event.data);
|
||||
reactOnMessageFromServer(parsed);
|
||||
processCommand(parsed);
|
||||
console.log("Message from server: ", event.data);
|
||||
console.log("Message from server");
|
||||
});
|
||||
socket.addEventListener("close", (_event) => {
|
||||
console.log("Closed socket");
|
||||
|
@ -285,7 +285,8 @@ const processCommand = (function () {
|
||||
function resolveIceCandidates() {
|
||||
if (delay) clearTimeout(delay)
|
||||
resolved = true
|
||||
console.log("LALAL resolveIceCandidates", JSON.stringify(candidates))
|
||||
// console.log("resolveIceCandidates", JSON.stringify(candidates))
|
||||
console.log("resolveIceCandidates")
|
||||
const iceCandidates = serialize(candidates)
|
||||
candidates = []
|
||||
resolve(iceCandidates)
|
||||
@ -293,7 +294,8 @@ const processCommand = (function () {
|
||||
|
||||
function sendIceCandidates() {
|
||||
if (candidates.length === 0) return
|
||||
console.log("LALAL sendIceCandidates", JSON.stringify(candidates))
|
||||
// console.log("sendIceCandidates", JSON.stringify(candidates))
|
||||
console.log("sendIceCandidates")
|
||||
const iceCandidates = serialize(candidates)
|
||||
candidates = []
|
||||
sendMessageToNative({resp: {type: "ice", iceCandidates}})
|
||||
@ -417,7 +419,7 @@ const processCommand = (function () {
|
||||
iceCandidates: await activeCall.iceCandidates,
|
||||
capabilities: {encryption},
|
||||
}
|
||||
console.log("LALALs", JSON.stringify(resp))
|
||||
// console.log("offer response", JSON.stringify(resp))
|
||||
break
|
||||
}
|
||||
case "offer":
|
||||
@ -431,7 +433,7 @@ const processCommand = (function () {
|
||||
const {media, aesKey, iceServers, relay} = command
|
||||
activeCall = await initializeCall(getCallConfig(!!aesKey, iceServers, relay), media, aesKey)
|
||||
const pc = activeCall.connection
|
||||
console.log("LALALo", JSON.stringify(remoteIceCandidates))
|
||||
// console.log("offer remoteIceCandidates", JSON.stringify(remoteIceCandidates))
|
||||
await pc.setRemoteDescription(new RTCSessionDescription(offer))
|
||||
const answer = await pc.createAnswer()
|
||||
await pc.setLocalDescription(answer)
|
||||
@ -443,7 +445,7 @@ const processCommand = (function () {
|
||||
iceCandidates: await activeCall.iceCandidates,
|
||||
}
|
||||
}
|
||||
console.log("LALALo", JSON.stringify(resp))
|
||||
// console.log("answer response", JSON.stringify(resp))
|
||||
break
|
||||
case "answer":
|
||||
if (!pc) {
|
||||
@ -455,7 +457,7 @@ const processCommand = (function () {
|
||||
} else {
|
||||
const answer: RTCSessionDescriptionInit = parse(command.answer)
|
||||
const remoteIceCandidates: RTCIceCandidateInit[] = parse(command.iceCandidates)
|
||||
console.log("LALALa", JSON.stringify(remoteIceCandidates))
|
||||
// console.log("answer remoteIceCandidates", JSON.stringify(remoteIceCandidates))
|
||||
await pc.setRemoteDescription(new RTCSessionDescription(answer))
|
||||
addIceCandidates(pc, remoteIceCandidates)
|
||||
resp = {type: "ok"}
|
||||
@ -523,7 +525,7 @@ const processCommand = (function () {
|
||||
function addIceCandidates(conn: RTCPeerConnection, iceCandidates: RTCIceCandidateInit[]) {
|
||||
for (const c of iceCandidates) {
|
||||
conn.addIceCandidate(new RTCIceCandidate(c))
|
||||
console.log("LALAL addIceCandidates", JSON.stringify(c))
|
||||
// console.log("addIceCandidates", JSON.stringify(c))
|
||||
}
|
||||
}
|
||||
|
||||
@ -546,9 +548,8 @@ const processCommand = (function () {
|
||||
if (useWorker && !call.worker) {
|
||||
const workerCode = `const callCrypto = (${callCryptoFunction.toString()})(); (${workerFunction.toString()})()`
|
||||
call.worker = new Worker(URL.createObjectURL(new Blob([workerCode], {type: "text/javascript"})))
|
||||
call.worker.onerror = ({error, filename, lineno, message}: ErrorEvent) =>
|
||||
console.log(JSON.stringify({error, filename, lineno, message}))
|
||||
call.worker.onmessage = ({data}) => console.log(JSON.stringify({message: data}))
|
||||
call.worker.onerror = ({error, filename, lineno, message}: ErrorEvent) => console.log({error, filename, lineno, message})
|
||||
// call.worker.onmessage = ({data}) => console.log(JSON.stringify({message: data}))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Override defaults to enable worker on Chrome and Safari
|
||||
useWorker = (window as any).safari !== undefined || navigator.userAgent.indexOf("Chrome") != -1
|
||||
useWorker = typeof window.Worker !== "undefined"
|
||||
|
||||
// Create WebSocket connection.
|
||||
const socket = new WebSocket(`ws://${location.host}`)
|
||||
@ -7,7 +7,7 @@ const socket = new WebSocket(`ws://${location.host}`)
|
||||
socket.addEventListener("open", (_event) => {
|
||||
console.log("Opened socket")
|
||||
sendMessageToNative = (msg: WVApiMessage) => {
|
||||
console.log("Message to server: ", msg)
|
||||
console.log("Message to server")
|
||||
socket.send(JSON.stringify(msg))
|
||||
}
|
||||
})
|
||||
@ -16,7 +16,7 @@ socket.addEventListener("message", (event) => {
|
||||
const parsed = JSON.parse(event.data)
|
||||
reactOnMessageFromServer(parsed)
|
||||
processCommand(parsed)
|
||||
console.log("Message from server: ", event.data)
|
||||
console.log("Message from server")
|
||||
})
|
||||
|
||||
socket.addEventListener("close", (_event) => {
|
||||
|
Loading…
Reference in New Issue
Block a user