Merge pull request #157 from thecodingmachine/fixing_long_disconnect
Adding connecting spinner and blinking error to webrtc display
This commit is contained in:
commit
bd3be2a138
3 changed files with 100 additions and 1 deletions
|
@ -143,6 +143,8 @@ export class MediaManager {
|
|||
let color = this.getColorByString(userName);
|
||||
elementRemoteVideo.insertAdjacentHTML('beforeend', `
|
||||
<div id="div-${userId}" class="video-container" style="border-color: ${color};">
|
||||
<div class="connecting-spinner"></div>
|
||||
<div class="rtc-error" style="display: none"></div>
|
||||
<i style="background-color: ${color};">${userName}</i>
|
||||
<img id="microphone-${userId}" src="resources/logos/microphone-close.svg">
|
||||
<video id="${userId}" autoplay></video>
|
||||
|
@ -228,6 +230,43 @@ export class MediaManager {
|
|||
element.remove();
|
||||
}
|
||||
|
||||
isConnecting(userId : string): void {
|
||||
let connectingSpinnerDiv = this.getSpinner(userId);
|
||||
if (connectingSpinnerDiv === null) {
|
||||
return;
|
||||
}
|
||||
connectingSpinnerDiv.style.display = 'block';
|
||||
}
|
||||
|
||||
isConnected(userId : string): void {
|
||||
let connectingSpinnerDiv = this.getSpinner(userId);
|
||||
if (connectingSpinnerDiv === null) {
|
||||
return;
|
||||
}
|
||||
connectingSpinnerDiv.style.display = 'none';
|
||||
}
|
||||
|
||||
isError(userId : string): void {
|
||||
let element = document.getElementById(`div-${userId}`);
|
||||
if(!element){
|
||||
return;
|
||||
}
|
||||
let errorDiv = element.getElementsByClassName('rtc-error').item(0) as HTMLDivElement|null;
|
||||
if (errorDiv === null) {
|
||||
return;
|
||||
}
|
||||
errorDiv.style.display = 'block';
|
||||
}
|
||||
|
||||
private getSpinner(userId : string): HTMLDivElement|null {
|
||||
let element = document.getElementById(`div-${userId}`);
|
||||
if(!element){
|
||||
return null;
|
||||
}
|
||||
let connnectingSpinnerDiv = element.getElementsByClassName('connecting-spinner').item(0) as HTMLDivElement|null;
|
||||
return connnectingSpinnerDiv;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param str
|
||||
|
|
|
@ -161,9 +161,11 @@ export class SimplePeer {
|
|||
|
||||
peer.on('error', (err: any) => {
|
||||
console.error(`error => ${user.userId} => ${err.code}`, err);
|
||||
this.MediaManager.isError(user.userId);
|
||||
});
|
||||
|
||||
peer.on('connect', () => {
|
||||
this.MediaManager.isConnected(user.userId);
|
||||
console.info(`connect => ${user.userId}`);
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue