Merge branch 'develop' into 2daysLimit

Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com>

# Conflicts:
#	front/src/Connexion/RoomConnection.ts
This commit is contained in:
Gregoire Parant 2022-01-05 12:08:27 +01:00
commit 08847e1a64
72 changed files with 1712 additions and 1078 deletions

View file

@ -58,7 +58,6 @@ export const followUsersStore = createFollowUsersStore();
export const followUsersColorStore = derived(
[followStateStore, followRoleStore, followUsersStore],
([$followStateStore, $followRoleStore, $followUsersStore]) => {
console.log($followStateStore);
if ($followStateStore !== "active") {
return undefined;
}

View file

@ -360,32 +360,27 @@ const implementCorrectTrackBehavior = getNavigatorType() === NavigatorType.firef
/**
* Stops the camera from filming
*/
function applyCameraConstraints(currentStream: MediaStream | null, constraints: MediaTrackConstraints | boolean): void {
async function applyCameraConstraints(
currentStream: MediaStream | null,
constraints: MediaTrackConstraints | boolean
): Promise<void[]> {
if (!currentStream) {
return;
}
for (const track of currentStream.getVideoTracks()) {
toggleConstraints(track, constraints).catch((e) =>
console.error("Error while setting new camera constraints:", e)
);
return [];
}
return Promise.all(currentStream.getVideoTracks().map((track) => toggleConstraints(track, constraints)));
}
/**
* Stops the microphone from listening
*/
function applyMicrophoneConstraints(
async function applyMicrophoneConstraints(
currentStream: MediaStream | null,
constraints: MediaTrackConstraints | boolean
): void {
): Promise<void[]> {
if (!currentStream) {
return;
}
for (const track of currentStream.getAudioTracks()) {
toggleConstraints(track, constraints).catch((e) =>
console.error("Error while setting new audio constraints:", e)
);
return [];
}
return Promise.all(currentStream.getAudioTracks().map((track) => toggleConstraints(track, constraints)));
}
async function toggleConstraints(track: MediaStreamTrack, constraints: MediaTrackConstraints | boolean): Promise<void> {
@ -477,8 +472,8 @@ export const localStreamStore = derived<Readable<MediaStreamConstraints>, LocalS
}
}
applyMicrophoneConstraints(currentStream, constraints.audio || false);
applyCameraConstraints(currentStream, constraints.video || false);
applyMicrophoneConstraints(currentStream, constraints.audio || false).catch((e) => console.error(e));
applyCameraConstraints(currentStream, constraints.video || false).catch((e) => console.error(e));
if (implementCorrectTrackBehavior) {
//on good navigators like firefox, we can instantiate the stream once and simply disable or enable the tracks as needed

View file

@ -3,6 +3,7 @@ import type { PlayerInterface } from "../Phaser/Game/PlayerInterface";
import type { RoomConnection } from "../Connexion/RoomConnection";
import { getRandomColor } from "../WebRtc/ColorGenerator";
import { localUserStore } from "../Connexion/LocalUserStore";
import room from "../Api/iframe/room";
let idCount = 0;
@ -19,7 +20,8 @@ function createPlayersStore() {
connectToRoomConnection: (roomConnection: RoomConnection) => {
players = new Map<number, PlayerInterface>();
set(players);
roomConnection.onUserJoins((message) => {
// TODO: it would be cool to unsubscribe properly here
roomConnection.userJoinedMessageStream.subscribe((message) => {
update((users) => {
users.set(message.userId, {
userId: message.userId,
@ -33,9 +35,9 @@ function createPlayersStore() {
return users;
});
});
roomConnection.onUserLeft((userId) => {
roomConnection.userLeftMessageStream.subscribe((message) => {
update((users) => {
users.delete(userId);
users.delete(message.userId);
return users;
});
});

View file

@ -156,7 +156,7 @@ export const screenSharingLocalStreamStore = derived<Readable<MediaStreamConstra
error: e instanceof Error ? e : new Error("An unknown error happened"),
});
}
})();
})().catch((e) => console.error(e));
}
);