voximplant / react-native-voximplant

Voximplant mobile SDK for React Native (iOS/Android)
http://voximplant.com
205 stars 39 forks source link

Group Video Call #126

Closed alex-evans123 closed 4 years ago

alex-evans123 commented 4 years ago

Hi @YuliaGrigorieva I'm implementing video call using callConference but can not find any resources, group call should be like whatsApp or GoogleHangouts. Please point me to the right direction.

Problem I'm facing is CallConference creates a conference and others have to join it, it doesn't notify the other participant, I couldn't find anything that wants me to add a participant list to the conference, please help

alex-evans123 commented 4 years ago

Any one here to help??

alex-evans123 commented 4 years ago

Any one here to help??

@YuliaGrigorieva ??

YuliaGrigorieva commented 4 years ago

Hello @alex-evans123 ,

Do I understand correctly that you need the following case: when a user starts a conference, other participants (that user has selected for this call) should receive IncomingCall event and should be able to join a call by answering it?

Best regards, Yulia Grigorieva

alex-evans123 commented 4 years ago

yes you are right

On Fri, Oct 2, 2020, 10:49 PM YuliaGrigorieva notifications@github.com wrote:

Hello @alex-evans123 https://github.com/alex-evans123 ,

Do I understand correctly that you need the following case: when a user starts a conference, other participants (that user has selected for this call) should receive IncomingCall event and should be able to join a call by answering it?

Best regards, Yulia Grigorieva

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/voximplant/react-native-voximplant/issues/126#issuecomment-702871411, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOHY6EUUDZ3D2PTQOZ7SYOTSIYHC3ANCNFSM4R7OHPAA .

YuliaGrigorieva commented 4 years ago

Hello @alex-evans123 ,

All you need is to modify your VoxEngine scenario as it describes how the call should be processed.

I assume you have already read this article and setup a VoxEngine scenario for a video conference based on its Step 4 - VoxEngine: set up Voximplant application with JS scenarios

To implement your case you need to change this part of the code:

VoxEngine.addEventListener(AppEvents.CallAlerting, function (e) {
  e.call.answer();
  partsCounter = partsCounter + 1;
  const endpoint = conf.add({
    call: e.call,
    mode: "FORWARD",
    direction: "BOTH", scheme: e.scheme
  });
  Logger.write(`New endpoint was added ID: ${endpoint.id}`);
});

to the following one:

VoxEngine.addEventListener(AppEvents.CallAlerting, function (e) {
  e.call.answer();
  partsCounter = partsCounter + 1;
  const endpoint = conf.add({
    call: e.call,
    mode: "FORWARD",
    direction: "BOTH", scheme: e.scheme
  });

  Logger.write(`New endpoint was added ID: ${endpoint.id}`);

  function checkForTermination() {
    if (partsCounter === 0) {
     conf.stop();
     conf = null;
    }
  }

  function participantDisconnected() {
    partsCounter = partsCounter - 1;
    if (partsCounter === 0) {
      setTimeout(checkForTermination, 1000 * 10); // wait for 10 ceconds
    }
  }

  e.call.addEventListener(CallEvents.Disconnected, function (e) {
    participantDisconnected();
  });
  let user = e.customData;
  let callParticipant = VoxEngine.callUser(user, "myconf", "Conference call", {}, true);

  callParticipant.addEventListener(CallEvents.Connected, function(e) {
    endpointParticipant = conf.add({
      call: e.call,
      mode: "FORWARD",
      direction: "BOTH", scheme: e.scheme});
  });
  callParticipant.addEventListener(CallEvents.Disconnected, function(e) {
      participantDisconnected();
  });
});

Some notes and explanations:

  1. the scenario gets Voximplant users names (participants) from the custom data in AppEvents.CallAlerting event handler. This event is invoked when you make an outgoing conference call from the SDK via Client.callConference("myconf", callSettings). The user names should be passed in callSettings.customData
  2. after it makes outgoing calls to call participants using CallUser method.
  3. you need to subscribe to the CallEvents.Connected event to join the user to the conference call, when he answers the incoming call on the client.
  4. you also need to subscribe to the CallEvents.Disconnected event to end the conference call when all endpoints have left the conference call.
  5. the provided example demonstrates the approach with one user name passed via custom data, you can change it to handle multiple user names.

Best regards, Yulia Grigorieva

alex-evans123 commented 4 years ago

Thank you for the support.