2017-10-09 18:48:05 +02:00
|
|
|
import { Injectable } from '@angular/core';
|
2018-06-04 14:27:37 +02:00
|
|
|
import { Subject } from 'rxjs';
|
2017-10-09 18:48:05 +02:00
|
|
|
|
2019-02-06 15:04:49 +01:00
|
|
|
import { Event } from 'openvidu-browser';
|
|
|
|
|
2022-11-23 17:14:38 +01:00
|
|
|
import * as stringify from 'json-stringify-safe';
|
2022-11-08 14:20:42 +01:00
|
|
|
|
2017-10-09 18:48:05 +02:00
|
|
|
@Injectable()
|
|
|
|
export class TestFeedService {
|
|
|
|
|
2022-11-08 14:20:42 +01:00
|
|
|
lastEvent: { user: number, event: Event };
|
2017-10-09 18:48:05 +02:00
|
|
|
newLastEvent$ = new Subject<any>();
|
|
|
|
|
|
|
|
constructor() { }
|
|
|
|
|
|
|
|
getLastEvent() {
|
|
|
|
return this.lastEvent;
|
|
|
|
}
|
|
|
|
|
2022-11-08 14:20:42 +01:00
|
|
|
pushNewEvent({ user: number, event: Event }) {
|
|
|
|
this.lastEvent = { user: number, event: Event };
|
2017-10-09 18:48:05 +02:00
|
|
|
this.newLastEvent$.next(this.lastEvent);
|
|
|
|
}
|
|
|
|
|
2022-11-08 14:20:42 +01:00
|
|
|
stringifyEventNoCircularDependencies(event: Event): string {
|
|
|
|
return stringify(event, (key, value) => {
|
|
|
|
// Remove unnecessary properties
|
|
|
|
if (key == 'ee' || key == 'openvidu' || key == 'userHandlerArrowHandler' || key == 'handlers') {
|
2022-11-23 17:14:38 +01:00
|
|
|
return undefined;
|
2022-11-08 14:20:42 +01:00
|
|
|
}
|
2022-11-23 17:14:38 +01:00
|
|
|
|
|
|
|
return value;
|
2022-11-08 14:20:42 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-10-09 18:48:05 +02:00
|
|
|
}
|