Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} else {
let data;
try {
data = JSON.parse(e.data);
} catch (e) {
console.log(e.data);
return;
}
switch (data.type) {
case CONST.MESSAGE_TYPE_STREAM_INFO:
if (converter) {
converter.appendRawData(new Uint8Array([]));
converter.pause();
}
streamInfo = data;
converter = new VideoConverter(element, data.frameRate, DEFAULT_FPF);
converter.play();
break;
case CONST.MESSAGE_TYPE_TEXT:
console.log(data.message);
break;
default:
console.log(e.data);
}
}
}, false);