ConnectyCube / connectycube-reactnative-samples

Chat and Video Chat code samples for React Native, ConnectyCube
https://connectycube.com
Apache License 2.0
125 stars 111 forks source link

What kind of feedback comes via onCallListener? #195

Closed tahademirer closed 3 years ago

tahademirer commented 3 years ago

Hi! Can you explain how onCallListener works? What kind of feedback or response object comes through the listener? Let's assume a simple scenairo. I have created the video session for User1 and attached the media to the stream. Now User1 can see himself on the screen. When I star call with session.call, what happens? Does User2 gets a response via onCallListener? If it is, what kind of response? Thanks!

ccvlad commented 3 years ago

Hi, @tahademirer

Hi! Can you explain how onCallListener works? What kind of feedback or response object comes through the listener? Let's assume a simple scenairo. I have created the video session for User1 and attached the media to the stream. Now User1 can see himself on the screen. When I star call with session.call, what happens?

One user uses session.call(extension) and sends a signaling message with the session and any data as object (extension) via XMPP chat. Second user receives the signaling message (XMPP's data - a stanza) and the message is parsing to define which listener should be called (ConnectyCube.videochat.onCallListener = (session, extension) => {...} in this case) https://developers.connectycube.com/js/videocalling?id=initiate-a-call

Does User2 gets a response via onCallListener? If it is, what kind of response? Thanks!

User2 receives the session and object with data in ConnectyCube.videochat.onCallListener(session, extension) Then User2 should accept or reject the incoming call using the session from the onCallListener:

ConnectyCube.videochat.onCallListener = (session, extension) => {
  session.accept({}); // the `onAcceptCallListener` will fired on opponent's side
  // or `session.reject({})` - the `onRejecttCallListener` will fired on opponent's side
  // if user won't answer the `onUserNotAnswerListener` will fired on opponent's side after interval.
}

After connection would establish, both users will receives a remote stream from opponent:

ConnectyCube.videochat.onRemoteStreamListener = (session, userID, remoteStream) => {
  console.log(`Remote stream: ${remoteStream}`);
  console.log(`From user with ID: ${userID}`);
}
tahademirer commented 3 years ago

Thanks!