Skip to content
Snippets Groups Projects
Unverified Commit 7dfeca18 authored by Florian Raith's avatar Florian Raith Committed by GitHub
Browse files

Add setting to mute everyone (#61)

parent 9c7f7810
No related branches found
No related tags found
No related merge requests found
async function START_RECORDING() {
console.log('start recording');
// const stream = await navigator.mediaDevices.getDisplayMedia({
// preferCurrentTab: true,
// });
const stream = await new Promise((resolve, reject) => {
chrome.tabCapture.capture(
{
......@@ -31,19 +25,10 @@ async function START_RECORDING() {
const promise = new Promise((resolve) => {
const peer = new peerjs.Peer();
// peer.on('call', (call) => {
// call.answer(stream);
// });
peer.on('open', (id) => {
resolve(id);
console.log('open peer:', id);
peer.on('connection', (conn) => {
console.log('established connection:', conn);
conn.on('open', () => {
console.log('connected: ' + conn.peer);
conn.send('hello from the server');
peer.call(conn.peer, stream);
});
......@@ -55,5 +40,5 @@ async function START_RECORDING() {
}
async function STOP_RECORDING() {
console.log('stop recording');
//
}
......@@ -9,7 +9,7 @@ import {
import { MikroORM, UseRequestContext } from '@mikro-orm/core';
import { Server, Socket } from 'socket.io';
import { ChannelService } from './channel.service';
import { Channel } from './channel';
import { Channel, Settings } from './channel';
import * as process from 'process';
import * as dotenv from 'dotenv';
import { BrowserService } from '../browser/browser.service';
......@@ -167,6 +167,7 @@ export class ChannelGateway implements OnGatewayConnection {
channelId: channel.id,
whiteboardCanvas: channel.canvasJSON,
},
settings: channel.settings,
teacher,
students,
};
......@@ -311,6 +312,41 @@ export class ChannelGateway implements OnGatewayConnection {
return true;
}
/**
* Handle an 'update-settings' event to update channel settings.
*
* @param client The connected socket client.
* @param payload The payload containing settings.
* @returns A boolean indicating success.
*/
@SubscribeMessage('update-settings')
@UseRequestContext()
public async updateSettings(
@ConnectedSocket() client: Socket,
@MessageBody() payload: Settings,
) {
const channel = await this.channels.fromClientOrFail(client);
channel.settings = payload;
this.server.to(channel.id).emit('update-settings', payload);
return true;
}
@SubscribeMessage('disable-audio-for')
@UseRequestContext()
public async disableAudioFor(
@ConnectedSocket() client: Socket,
@MessageBody() payload: { userId: string },
) {
const channel = await this.channels.fromClientOrFail(client);
channel.disableAudioFor(payload.userId);
this.server.to(channel.id).emit('disable-audio-for', payload.userId);
return true;
}
/**
* Handle an 'close-channel' event to close a channel.
* @param client The connected socket client.
......
......@@ -19,6 +19,10 @@ export interface Student extends ChannelUser {
permission: boolean;
}
export interface Settings {
globalMute: boolean;
}
/**
* Represents a channel for a room in the application.
*/
......@@ -30,6 +34,10 @@ export class Channel {
public canvasJSON: string;
public settings: Settings = {
globalMute: false,
};
/**
* Creates a new Channel instance.
*
......@@ -208,6 +216,14 @@ export class Channel {
}
}
public disableAudioFor(studentId: string) {
const student = this.getStudent(studentId);
if (student) {
student.audio = false;
}
}
/**
* Updates the hand signal setting of a student.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment