Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

189
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!