diff --git a/openvidu-testapp/src/app/components/test-sessions/test-sessions.component.ts b/openvidu-testapp/src/app/components/test-sessions/test-sessions.component.ts
index 4bff8df3..bdb486ed 100644
--- a/openvidu-testapp/src/app/components/test-sessions/test-sessions.component.ts
+++ b/openvidu-testapp/src/app/components/test-sessions/test-sessions.component.ts
@@ -38,19 +38,7 @@ export class TestSessionsComponent implements OnInit, OnDestroy {
this.eventsInfoSubscription = this.testFeedService.newLastEvent$.subscribe(
newEvent => {
- const getCircularReplacer = () => {
- const seen = new WeakSet();
- return (key, value) => {
- if (typeof value === "object" && value !== null) {
- if (seen.has(value)) {
- return;
- }
- seen.add(value);
- }
- return value;
- };
- };
- (window as any).myEvents += ('
' + JSON.stringify(newEvent, getCircularReplacer()));
+ (window as any).myEvents += ('
' + this.stringifyEventNoCircularDependencies(newEvent));
});
}
@@ -112,4 +100,28 @@ export class TestSessionsComponent implements OnInit, OnDestroy {
this.loadSubs(subs);
}
+ stringifyEventNoCircularDependencies(event: Event): string {
+ const cache = [];
+ return JSON.stringify(event, function (key, value) {
+ if (key !== 'ee' && key !== 'openvidu') {
+ if (typeof value === 'object' && value !== null) {
+ if (cache.indexOf(value) !== -1) {
+ // Duplicate reference found
+ try {
+ // If this value does not reference a parent
+ return JSON.parse(JSON.stringify(value));
+ } catch (error) {
+ return;
+ }
+ }
+ // Store value in our collection
+ cache.push(value);
+ }
+ return value;
+ } else {
+ return;
+ }
+ });
+ }
+
}