is not working with simple-peer

May 15, 2019, at 8:30 PM

i am willing to build one-to-one video chatroom with & Simple-Peer and for one-to-one algorithm i used rooms. but it is not working with that so i got confused. before this, i had an algorithm which worked without rooms but it worked for only 2 persons and if third one tried to connect s/he was getting "waiting" message. in my current algorithm, room's "name" is number. if there is only one user in the room it is emitting special event and when second one connects room's "name" is incremented and third user gets to "2" room and .... here is my code:

Server side:

vchns.on('connection', async function(socket){
  let room = vnumb;
  socket.current_vroom = room,clients)=>{
    if(err) console.log(err);
    if(clients.length < 2){
      if(clients.length == 1){
    if(clients.length >= 2){

  socket.on('Offer', SendOffer);
  socket.on('Answer', SendAnswer);

  function SendOffer(offer){'BackOffer', offer);
  function SendAnswer(data){'BackAnswer', data);

Client side:

let client = {}
navigator.mediaDevices.getUserMedia({video: true, audio: true})
localVideo.srcObject = stream;;
function initPeer(type){
 let peer = new Peer({initiator: (type == 'init')? true : false, stream: stream, trickle: false});
peer.on('stream', (stream)=>{
return peer;
function MakePeer(){
   client.gotAnswer = false;
   let peer = initPeer('init');
   peer.on('signal', function(data){
         socket.emit('Offer', data)
 client.peer = peer
  function FrontAnswer(offer){
    let peer = initPeer('notInit');
    peer.on('signal', (data)=>{
    socket.emit('Answer', data);
   function SignalAnswer(answer){
     client.gotAnswer = true;
     let peer = client.peer;
   function CreateVideo(stream){
     let video = document.createElement('video'); = 'remoteVideo';
     video.srcObject = stream;
  socket.on('BackOffer', FrontAnswer)
  socket.on('BackAnswer', SignalAnswer);
  socket.on('CreatePeer', MakePeer)

so what is wrong?


ORM for oracle DB in nodejs

ORM for oracle DB in nodejs

could you please suggest me better ORM for Oracle DB ?

Get loopback models using loopback-datasource-juggler

Get loopback models using loopback-datasource-juggler

Is there any other way other than getting the loopback model by using app object in a custom js file?

How to test mongoose.connect callback method with Jest

How to test mongoose.connect callback method with Jest

I've started making a new Express application, and the testing framework of choice is Jest

Why isn&#39;t my peer-js chatroom system working?

Why isn't my peer-js chatroom system working?

I've got a chatroom system where a user can create a chatroom and then talk ONLY in voice chat, however, now, it calls my friend, but I can't hear them and the audio element doesn't get createdHere is my console output