feat: add sounds when user joins/leaves call (#587)

This commit is contained in:
Evilhotdog 2022-04-29 15:22:18 +01:00 committed by GitHub
parent 2b8b9c959f
commit 4c87bc54a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,6 +4,8 @@ import { types } from "mediasoup-client";
import { Device, Producer, Transport } from "mediasoup-client/lib/types";
import { useApplicationState } from "../../mobx/State";
import Signaling from "./Signaling";
import {
ProduceType,
@ -58,6 +60,8 @@ export default class VoiceClient extends EventEmitter<VoiceEvents> {
this.isDeaf = false;
const state = useApplicationState();
this.signaling.on(
"data",
(json) => {
@ -65,11 +69,13 @@ export default class VoiceClient extends EventEmitter<VoiceEvents> {
switch (json.type) {
case WSEventType.UserJoined: {
this.participants.set(data.id, {});
state.settings.sounds.playSound("call_join");
this.emit("userJoined", data.id);
break;
}
case WSEventType.UserLeft: {
this.participants.delete(data.id);
state.settings.sounds.playSound("call_leave");
this.emit("userLeft", data.id);
if (this.recvTransport) this.stopConsume(data.id);