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

307
Visualizações
PeerJs peer.connections deprecated

I am trying to get all peers that are currently connected to me, but it says connections is deprecated.

const peer = new Peer('my_id');
const connections = peer.connections;

Documentation says: We recommend keeping track of connections yourself rather than relying on this hash.

Let's say I keep track of all peers id in array. How should I handle the ids so that I get the same result as with peer.connections ?

Example: peer.connections returns: peer.connections console.log

What method do I need to call to get the same results from peer id in my array?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I think you should create a listener when a connection is established. You may achieve this by implementing a wrapper that will unify client usage of peer js

class MyPeer {
  constructor() {
    this.instance = new Peer()
  }

  async connect() {
    return new Promise(resolve => {
      this.connection = peer.connect(new Date().getTime()) // create a unique id for each connection

      this.connection.on('open', () => resolve(this.connection))
    })
  }
}

Assuming you are taking this (very naïve, without proper error handling) implementation, you may keep track of connections like this

const peer = new MyPeer()
   
const connection = await peer.connect()
myConnectionsArray.push(connection)

It worth mentioning that you may remove connections from array when a connection is closed and probably wrap everything in a class (say ConnectionsManagaer or something similar). Besides that, it should satisfy your request

about 4 years ago · Juan Pablo Isaza Relatório
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