Adding condition to enable reporting only on private rooms

This commit is contained in:
David Négrier 2020-10-15 17:58:27 +02:00
parent 62dfb68aaf
commit 0ea7240834
3 changed files with 19 additions and 17 deletions

View file

@ -592,7 +592,7 @@ export class GameScene extends ResizableScene implements CenterListener {
}));
// When connection is performed, let's connect SimplePeer
this.simplePeer = new SimplePeer(this.connection);
this.simplePeer = new SimplePeer(this.connection, !this.room.isPublic);
this.GlobalMessageManager = new GlobalMessageManager(this.connection);
const self = this;

View file

@ -342,7 +342,7 @@ export class MediaManager {
* @param reportCallBack
* @param userName
*/
addActiveVideo(userId: string, reportCallBack: ReportCallback, userName: string = ""){
addActiveVideo(userId: string, reportCallBack: ReportCallback|undefined, userName: string = ""){
this.webrtcInAudio.play();
userName = userName.toUpperCase();
@ -354,18 +354,22 @@ export class MediaManager {
<div class="rtc-error" style="display: none"></div>
<i id="name-${userId}" style="background-color: ${color};">${userName}</i>
<img id="microphone-${userId}" src="resources/logos/microphone-close.svg">
<img id="report-${userId}" class="report active" src="resources/logos/report.svg">
<video id="${userId}" autoplay></video>
` +
((reportCallBack!==undefined)?`<img id="report-${userId}" class="report active" src="resources/logos/report.svg">`:'')
+
`<video id="${userId}" autoplay></video>
</div>
`;
layoutManager.add(DivImportance.Normal, userId, html);
const reportBtn = this.getElementByIdOrFail<HTMLDivElement>(`report-${userId}`);
reportBtn.addEventListener('click', (e: MouseEvent) => {
e.preventDefault();
this.showReportModal(userId, userName, reportCallBack);
});
if (reportCallBack) {
const reportBtn = this.getElementByIdOrFail<HTMLDivElement>(`report-${userId}`);
reportBtn.addEventListener('click', (e: MouseEvent) => {
e.preventDefault();
this.showReportModal(userId, userName, reportCallBack);
});
}
this.remoteVideo.set(userId, this.getElementByIdOrFail<HTMLVideoElement>(userId));
}

View file

@ -29,8 +29,6 @@ export interface PeerConnectionListener {
* This class manages connections to all the peers in the same group as me.
*/
export class SimplePeer {
private Connection: RoomConnection;
private WebRtcRoomId: string;
private Users: Array<UserSimplePeerInterface> = new Array<UserSimplePeerInterface>();
private PeerScreenSharingConnectionArray: Map<number, ScreenSharingPeer> = new Map<number, ScreenSharingPeer>();
@ -40,9 +38,7 @@ export class SimplePeer {
private readonly stopLocalScreenSharingStreamCallback: StopScreenSharingCallback;
private readonly peerConnectionListeners: Array<PeerConnectionListener> = new Array<PeerConnectionListener>();
constructor(Connection: RoomConnection, WebRtcRoomId: string = "test-webrtc") {
this.Connection = Connection;
this.WebRtcRoomId = WebRtcRoomId;
constructor(private Connection: RoomConnection, private enableReporting: boolean) {
// We need to go through this weird bound function pointer in order to be able to "free" this reference later.
this.sendLocalVideoStreamCallback = this.sendLocalVideoStream.bind(this);
this.sendLocalScreenSharingStreamCallback = this.sendLocalScreenSharingStream.bind(this);
@ -148,9 +144,11 @@ export class SimplePeer {
mediaManager.removeActiveVideo("" + user.userId);
//TODO ad condition isPublic or annonyme
mediaManager.addActiveVideo("" + user.userId, (comment: string) => {
this.reportUser(user.userId, comment);
}, name);
const reportCallback = this.enableReporting ? (comment: string) => {
this.reportUser(user.userId, comment);
}: undefined;
mediaManager.addActiveVideo("" + user.userId, reportCallback, name);
const peer = new VideoPeer(user.userId, user.initiator ? user.initiator : false, this.Connection);
// When a connection is established to a video stream, and if a screen sharing is taking place,