muaz-khan / RTCMultiConnection

RTCMultiConnection is a WebRTC JavaScript library for peer-to-peer applications (screen sharing, audio/video conferencing, file sharing, media streaming etc.)
https://muazkhan.com:9001/
MIT License
2.56k stars 1.38k forks source link

Problem in connection.join function #405

Open vikasvyas946 opened 7 years ago

vikasvyas946 commented 7 years ago

Hello

i am working on video conferencing in this i want to send request users to join conference for this i have user V3 version of rtc multiconnection in this i am sending request user by their name here is sample code

connection.connectSocket(function(socket) 
{
   document.getElementById('sendbutton').onclick = function() 
  {
      connection.open(roomid);   

      targetUserId               = document.getElementById('sender').value;
      var str = targetUserId;
      var res = str.split(",");

      for(i=0;i<res.length;i++)
     {
         if(res[i] != "" || typeof res[i] != "undefined")
        {  
           myval = res[i];

           var customMessage = 'Join Conference.';
           socket.emit(connection.socketCustomEvent, 
           {
              sender: connection.userid,
              customMessage: customMessage,
              remoteUserId:myval,
              roomids: roomid
           });
         }
      } 
   };
   // listen custom messages from server
   socket.on(connection.socketCustomEvent, function(message) 
   {
        if(message.remoteUserId == connection.userid)
       { 
           if(confirm("You want to join conference ?"))
           {
              connection.join(message.roomid)
           }  
           else
           {
              alert("No");
           }
       } 
   });
});

After accepting request not connect to each other.

Thanks in advance

karamata commented 7 years ago

after this code run

// listen custom messages from server
   socket.on(connection.socketCustomEvent, function(message) 
   {
        if(message.remoteUserId == connection.userid)
       { 
           if(confirm("You want to join conference ?"))
           {
              connection.join(message.roomid)
           }  
           else
           {
              alert("No");
           }
       } 
   });

do you receive event connection.onNewParticipant ?

vikasvyas946 commented 7 years ago

Hello

i added this event and i get undefined participantId here is following code

 connection.connectSocket(function(socket) 
{
   document.getElementById('request').onclick = function() 
  {
      connection.open(roomid);
      targetUserId               = document.getElementById('sender').value;
      var str = targetUserId;
      var res = str.split(",");

      for(i=0;i<res.length;i++)
     {
         if(res[i] != "" || typeof res[i] != "undefined")
        {  
           myval = res[i];

           var customMessage = 'Join Conference.';
           socket.emit(connection.socketCustomEvent, 
           {
              sender: connection.userid,
              customMessage: customMessage,
              remoteUserId:myval,
              roomids: roomid
           }); 
         }
      }

   };

   // listen custom messages from server
   socket.on(connection.socketCustomEvent, function(message) 
   {
        if(message.remoteUserId == connection.userid)
       { 

            if(confirm("You want to join conference ?"))
           {
              connection.join(message.roomid)
           }  
           else
           {
              alert("No");
           }

       }  
   });

});

 var alreadyAllowed = {};
connection.onNewParticipant = function(participantId, userPreferences) { alert(participantId);
    if(alreadyAllowed[participantId]) {
        connection.addParticipationRequest(participantId, userPreferences);
        return;
    }

    var message = participantId + ' is trying to join your room. Confirm to accept his request.';
    if( window.confirm(messsage ) ) {
        connection.addParticipationRequest(participantId, userPreferences);
    }
};
karamata commented 7 years ago

hi @vikasvyas946 it's really hard to detect your issue without seeing total your connection configuration.

can you try to put this line of code into the end of your custom onNewParticipant

connection.acceptParticipationRequest(participantId, userPreferences);

idealy, can you checkout newest source code and debug at that line https://github.com/muaz-khan/RTCMultiConnection/blob/master/dist/RTCMultiConnection.js#L224 then console.log the message and post here

vikasvyas946 commented 7 years ago

Hello

The above link which you given is not working.

vikasvyas946 commented 7 years ago

Hello

Basically i want to create a skype like web app in this i want to request selected users if they are online then they can get request and if they accept then multiple users can conference each other.

Thanks

karamata commented 7 years ago

sorry, I just update link above, do you have alook at that demo, https://github.com/muaz-khan/RTCMultiConnection/tree/master/demos/MultiRTC/

or you can modify base on that source code to implement your story.

vikasvyas946 commented 7 years ago

i am following same steps but they cant connect each other can you please help me ?

karamata commented 7 years ago

I still try to investigate what problems firstly I recommend you need to try to run https://rtcmulticonnection.herokuapp.com/demos/MultiRTC/ if it's not run well, prolemns may be your browser

webRTC can not run on ios, safari, please notice that, I never have try run webRTC on linux but may be some distro can not run. I also try run webRTC on chromium on Raspberry but it's not working also.

vikasvyas946 commented 7 years ago

Hello

Thanks for your reply my question is that why connection.join not working when i am using this on custom socket event if you say then i can create fiddle so you can check what i mistaken

Thanks