Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

193
Visualizações
Party calls with peerjs

I'm trying to make a voice chat using some particular voice channels. I'm having trouble getting more than two users to interact at a time though.

From what I understand when it creates a call it seems that somehow it interrupts the previous one.

I've tried following Multi Party - Video Conference with peerJS

and convert it to make it compatible with my

Would anyone know the solution?

// when the user connect to the channel
  socket.on('user-connected', (data) => {
    if(document.querySelector(`#channel-user-${data.user_id}`) !== null) return;
    const connectedUsers = document.querySelectorAll(`#channel-image-${data.channel_id}`)[0];

    if (data.user_id === user_id && connectedUsers !== undefined) {
      for (let i = 0; i < connectedUsers.children.length; i++) { 

        // get all the users inside the channel
        const element = connectedUsers.children[i];
        const otherUser = element.id.split('-')[element.id.split('-').length - 1] 
        //this is the peer id

        // call it
        const call = peer.call(otherUser, localStream);
        call.on('stream', stream => {
          remoteStream = stream;
          const audio = document.createElement('audio');
          audio.srcObject = stream;
          audio.play();
        })
      }
    }
  //when receiving a call answer and play it
  peer.on('call', call => {
    console.log('Received call by', call.peer);
    call.answer(localStream);
    call.on('stream', stream => {
      remoteStream = stream;
      const audio = document.createElement('audio');
      audio.srcObject = stream;
      audio.play();
    })
  });
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda