Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

306
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda