Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
componentDidMount(){
if(global.rtcEngine) {
global.rtcEngine.release()
global.rtcEngine = null
}
if(!APPID) {
alert('Please provide APPID in App.jsx')
return
}
const consoleContainer = document.querySelector('#console')
let rtcEngine = new AgoraRtcEngine()
rtcEngine.initialize(APPID)
// listen to events
rtcEngine.on('joinedChannel', (channel, uid, elapsed) => {
consoleContainer.innerHTML = `join channel success ${channel} ${uid} ${elapsed}`
let localVideoContainer = document.querySelector('#local')
//setup render area for local user
rtcEngine.setupLocalVideo(localVideoContainer)
})
rtcEngine.on('error', (err, msg) => {
consoleContainer.innerHTML = `error: code ${err} - ${msg}`
})
rtcEngine.on('userJoined', (uid) => {
//setup render area for joined user
let remoteVideoContainer = document.querySelector('#remote')
rtcEngine.setupViewContentMode(uid, 1);
this.$nextTick(function () {
// Code that will run only after the
// entire view has been rendered
if(global.rtcEngine) {
global.rtcEngine.release()
global.rtcEngine = null
}
if(!APPID) {
alert('Please provide APPID in App.vue')
return
}
const consoleContainer = document.querySelector('#console')
let rtcEngine = new AgoraRtcEngine()
rtcEngine.initialize(APPID)
// listen to events
rtcEngine.on('joinedChannel', (channel, uid, elapsed) => {
consoleContainer.innerHTML = `join channel success ${channel} ${uid} ${elapsed}`
let localVideoContainer = document.querySelector('#local')
//setup render area for local user
rtcEngine.setupLocalVideo(localVideoContainer)
})
rtcEngine.on('error', (err, msg) => {
consoleContainer.innerHTML = `error: code ${err} - ${msg}`
})
rtcEngine.on('userJoined', (uid) => {
//setup render area for joined user
let remoteVideoContainer = document.querySelector('#remote')
rtcEngine.setupViewContentMode(uid, 1);
const consoleContainer = document.getElementById('agora-join-channel-console')
const sdkLogPath = path.resolve(os.homedir(), "./agoramainsdk.log")
const localVideoContainer = document.getElementById('join-channel-local-video')
const remoteVideoContainer = document.getElementById('join-channel-remote-video')
const APPID = global.AGORA_APPID || ""
if(!APPID) {
alert(`AGORA_APPID not found in environment variables`)
}
if(global.rtcEngine) {
// if rtc engine exists already, you must call release to free it first
global.rtcEngine.release()
}
let rtcEngine = new AgoraRtcEngine()
rtcEngine.initialize(APPID)
// listen to events
rtcEngine.on('joinedChannel', (channel, uid, elapsed) => {
consoleContainer.innerHTML = `joined channel ${channel} with uid ${uid}, elapsed ${elapsed}ms`
//setup render area for local user
rtcEngine.setupLocalVideo(localVideoContainer)
})
rtcEngine.on('error', (err, msg) => {
consoleContainer.innerHTML = `error: code ${err} - ${msg}`
})
rtcEngine.on('userJoined', (uid) => {
//setup render area for joined user
rtcEngine.setupViewContentMode(uid, 1);
rtcEngine.subscribe(uid, remoteVideoContainer)
})
getRtcEngine() {
if(!this.rtcEngine) {
this.rtcEngine = new AgoraRtcEngine()
this.rtcEngine.initialize(APP_ID)
this.subscribeEvents(this.rtcEngine)
window.rtcEngine = this.rtcEngine;
}
return this.rtcEngine
}
created() {
this.rtcEngine = new AgoraRtcEngine();
if (!APP_ID) {
return alert("APP_ID cannot be empty!");
} else {
this.rtcEngine.initialize(APP_ID);
}
},
mounted() {