class VideoCall {
constructor() {
this.pc = { iceConnectionState: 'new' };
this.streams = [];
}
async connect() {
this.pc.iceConnectionState = 'checking';
await Promise.resolve();
this.pc.iceConnectionState = 'connected';
this.streams.push('remote-video');
return this.pc.iceConnectionState;
}
handleConnectionChange() {
const states = ['new', 'checking', 'connected'];
return states.map(state => {
return this.pc.iceConnectionState === state ? `Status: ${state}` : null;
}).filter(Boolean);
}
}
const call = new VideoCall();
call.connect().then(() => {
console.log(call.handleConnectionChange());
}); Post #2519
4.97K
CHALLENGE
- ❤ 8