FEATURE: implemented a client side blacklist
This commit is contained in:
parent
b92b7304b0
commit
0c892e0243
16 changed files with 338 additions and 186 deletions
24
front/src/WebRtc/BlackListManager.ts
Normal file
24
front/src/WebRtc/BlackListManager.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
import {Subject} from 'rxjs';
|
||||
|
||||
class BlackListManager {
|
||||
private list: number[] = [];
|
||||
public onBlockStream: Subject<number> = new Subject();
|
||||
public onUnBlockStream: Subject<number> = new Subject();
|
||||
|
||||
isBlackListed(userId: number): boolean {
|
||||
return this.list.find((data) => data === userId) !== undefined;
|
||||
}
|
||||
|
||||
blackList(userId: number): void {
|
||||
if (this.isBlackListed(userId)) return;
|
||||
this.list.push(userId);
|
||||
this.onBlockStream.next(userId);
|
||||
}
|
||||
|
||||
cancelBlackList(userId: number): void {
|
||||
this.list.splice(this.list.findIndex(data => data === userId), 1);
|
||||
this.onUnBlockStream.next(userId);
|
||||
}
|
||||
}
|
||||
|
||||
export const blackListManager = new BlackListManager();
|
Loading…
Add table
Add a link
Reference in a new issue