mirror of https://github.com/OpenVidu/openvidu.git
openvidu-node-client: fix circular JSON stringify of Session objects
parent
5760f4e7ef
commit
3856cdded7
|
@ -200,7 +200,7 @@ export class Session {
|
||||||
*/
|
*/
|
||||||
public fetch(): Promise<boolean> {
|
public fetch(): Promise<boolean> {
|
||||||
return new Promise<boolean>((resolve, reject) => {
|
return new Promise<boolean>((resolve, reject) => {
|
||||||
const beforeJSON: string = JSON.stringify(this);
|
const beforeJSON: string = JSON.stringify(this, this.removeCircularOpenViduReference);
|
||||||
axios.get(
|
axios.get(
|
||||||
'https://' + this.ov.hostname + ':' + this.ov.port + OpenVidu.API_SESSIONS + '/' + this.sessionId,
|
'https://' + this.ov.hostname + ':' + this.ov.port + OpenVidu.API_SESSIONS + '/' + this.sessionId,
|
||||||
{
|
{
|
||||||
|
@ -214,7 +214,7 @@ export class Session {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
// SUCCESS response from openvidu-server
|
// SUCCESS response from openvidu-server
|
||||||
this.resetSessionWithJson(res.data);
|
this.resetSessionWithJson(res.data);
|
||||||
const afterJSON: string = JSON.stringify(this);
|
const afterJSON: string = JSON.stringify(this, this.removeCircularOpenViduReference);
|
||||||
const hasChanged: boolean = !(beforeJSON === afterJSON);
|
const hasChanged: boolean = !(beforeJSON === afterJSON);
|
||||||
console.log("Session info fetched for session '" + this.sessionId + "'. Any change: " + hasChanged);
|
console.log("Session info fetched for session '" + this.sessionId + "'. Any change: " + hasChanged);
|
||||||
resolve(hasChanged);
|
resolve(hasChanged);
|
||||||
|
@ -528,4 +528,15 @@ export class Session {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hidden
|
||||||
|
*/
|
||||||
|
private removeCircularOpenViduReference(key: string, value: any) {
|
||||||
|
if (key === 'ov' && value instanceof OpenVidu) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue