Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private startRtc = (userId: number, channelId: string): void => {
this.agoraClient = AgoraRTC.createClient({mode: "rtc", codec: "h264"});
this.agoraClient.init(this.props.agoraAppId, () => {
console.log("AgoraRTC client initialized");
}, (err: any) => {
console.log("AgoraRTC client init failed", err);
});
const localStream = AgoraRTC.createStream({
streamID: userId,
audio: true,
video: true,
});
localStream.init(() => {
console.log("getUserMedia successfully");
const netlessLocalStream = {
...localStream,
state: {isVideoOpen: true, isAudioOpen: true},
};
this.setState({localStream: netlessLocalStream});
netlessLocalStream.play("rtc_local_stream");
this.agoraClient.join(this.props.agoraAppId, channelId, userId, (uid: string) => {
this.props.setMediaState(true);
console.log("User " + uid + " join channel successfully");
this.agoraClient.publish(localStream, (err: any) => {
private startRtc = (uid: number, channelId: string): void => {
this.setSliderExtending();
this.setState({isStartBtnLoading: true});
if (!this.agoraClient) {
this.agoraClient = AgoraRTC.createClient({mode: "live", codec: "h264"});
this.agoraClient.init(this.props.agoraAppId, () => {
console.log("AgoraRTC client initialized");
}, (err: any) => {
console.log("AgoraRTC client init failed", err);
});
}
const localStream = AgoraRTC.createStream({
streamID: uid,
audio: true,
video: true,
screen: false,
});
localStream.init(() => {
console.log("getUserMedia successfully");
this.setState({localStream: localStream});
localStream.play("rtc_local_stream");
this.rtcClock = setInterval( () => this.setState({joinRoomTime: this.state.joinRoomTime + 1}), 1000);
this.setState({isStartBtnLoading: false});
this.agoraClient.join(this.props.agoraAppId, channelId, uid, (uid: number) => {
console.log("User " + uid + " join channel successfully");
if (!this.props.isRtcReadOnly) {
this.agoraClient.publish(localStream, (err: any) => {
console.log("Publish local stream error: " + err);
private startRtc = (uid: number, channelId: string): void => {
this.setSliderExtending();
this.setState({isStartBtnLoading: true});
if (!this.agoraClient) {
this.agoraClient = AgoraRTC.createClient({mode: "live", codec: "h264"});
this.agoraClient.init(this.props.agoraAppId, () => {
console.log("AgoraRTC client initialized");
}, (err: any) => {
console.log("AgoraRTC client init failed", err);
});
}
const localStream = AgoraRTC.createStream({
streamID: uid,
audio: true,
video: true,
screen: false,
});
localStream.init(() => {
console.log("getUserMedia successfully");
this.setState({localStream: localStream});
localStream.play("rtc_local_stream");
this.rtcClock = setInterval( () => this.setState({joinRoomTime: this.state.joinRoomTime + 1}), 1000);
this.setState({isStartBtnLoading: false});
this.agoraClient.join(this.props.agoraAppId, channelId, uid, (uid: number) => {
console.log("User " + uid + " join channel successfully");
if (!this.props.isRtcReadOnly) {
this.agoraClient.publish(localStream, (err: any) => {
console.log("Publish local stream error: " + err);