mirror of https://github.com/OpenVidu/openvidu.git
openvidu-browser: Fixed video data timeouts errors
Fixex and cleaned timeout and intervals in sendVideoData method when session is left or when loops are finishedpull/574/head
parent
2e5797e348
commit
293899de8a
|
@ -143,6 +143,14 @@ export class Session extends EventDispatcher {
|
||||||
* @hidden
|
* @hidden
|
||||||
*/
|
*/
|
||||||
stopSpeakingEventsEnabledOnce = false;
|
stopSpeakingEventsEnabledOnce = false;
|
||||||
|
/**
|
||||||
|
* @hidden
|
||||||
|
*/
|
||||||
|
private videoDataInterval: NodeJS.Timeout;
|
||||||
|
/**
|
||||||
|
* @hidden
|
||||||
|
*/
|
||||||
|
private videoDataTimeout: NodeJS.Timeout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hidden
|
* @hidden
|
||||||
|
@ -1122,6 +1130,7 @@ export class Session extends EventDispatcher {
|
||||||
|
|
||||||
forced = !!forced;
|
forced = !!forced;
|
||||||
logger.info('Leaving Session (forced=' + forced + ')');
|
logger.info('Leaving Session (forced=' + forced + ')');
|
||||||
|
this.stopVideoDataIntervals();
|
||||||
|
|
||||||
if (!!this.connection) {
|
if (!!this.connection) {
|
||||||
if (!this.connection.disposed && !forced) {
|
if (!this.connection.disposed && !forced) {
|
||||||
|
@ -1193,15 +1202,16 @@ export class Session extends EventDispatcher {
|
||||||
}
|
}
|
||||||
if (doInterval) {
|
if (doInterval) {
|
||||||
let loops = 1;
|
let loops = 1;
|
||||||
let timer = setTimeout(async function myTimer() {
|
this.videoDataInterval = setInterval(() => {
|
||||||
await obtainAndSendVideo();
|
|
||||||
if (loops < maxLoops) {
|
if (loops < maxLoops) {
|
||||||
loops++;
|
loops++;
|
||||||
timer = setTimeout(myTimer, intervalSeconds * 1000);
|
obtainAndSendVideo();
|
||||||
|
}else {
|
||||||
|
clearInterval(this.videoDataInterval);
|
||||||
}
|
}
|
||||||
}, intervalSeconds * 1000);
|
}, intervalSeconds * 1000);
|
||||||
} else {
|
} else {
|
||||||
setTimeout(obtainAndSendVideo, intervalSeconds * 1000);
|
this.videoDataTimeout = setTimeout(obtainAndSendVideo, intervalSeconds * 1000);
|
||||||
}
|
}
|
||||||
} else if (platform.isFirefoxBrowser() || platform.isFirefoxMobileBrowser() || platform.isIonicIos() || platform.isReactNative()) {
|
} else if (platform.isFirefoxBrowser() || platform.isFirefoxMobileBrowser() || platform.isIonicIos() || platform.isReactNative()) {
|
||||||
// Basic version for Firefox and Ionic iOS. They do not support stats
|
// Basic version for Firefox and Ionic iOS. They do not support stats
|
||||||
|
@ -1289,6 +1299,11 @@ export class Session extends EventDispatcher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private stopVideoDataIntervals(): void {
|
||||||
|
clearInterval(this.videoDataInterval);
|
||||||
|
clearTimeout(this.videoDataTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
private stringClientMetadata(metadata: any): string {
|
private stringClientMetadata(metadata: any): string {
|
||||||
if (typeof metadata !== 'string') {
|
if (typeof metadata !== 'string') {
|
||||||
return JSON.stringify(metadata);
|
return JSON.stringify(metadata);
|
||||||
|
|
Loading…
Reference in New Issue