ConnectyCube / connectycube-reactnative-samples

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

Call history or log and toggle between audio & video call #212

Closed arghyaMatrix closed 3 years ago

arghyaMatrix commented 3 years ago

How do I show of calls to user? is there any api for this please mention. Another question, How can I toggle between audio and video within a ongoing call. Please help Thanks

Krishna8077078 commented 3 years ago

hi arghya actually in this is not possible to get a call log u can achieve this feature with your own API for creating a call log

arghyaMatrix commented 3 years ago

Ok @Krishna8077078 How can I toggle between audio and video within a ongoing call?

Romick2005 commented 3 years ago

That depends of a technology you are using. For webrtc there is an option use video.

arghyaMatrix commented 3 years ago

I am using react-native-webrtc for video call. how can i achieve this?

DaveLomber commented 3 years ago

Basically, for call history you can use Data API

The flow is pretty like this:

1) Go to https://admin.connectycube.com, Custom module, and create a data schema, e.g. CallHistory, with the following fields:

  type: Integer
  mediaType: Integer
  participant_ids: Array of Integer
  date: String
  duration: Integer
  is_missed: Boolean
  call_user_id: Integer
  read: Boolean

Then set class permissions like this:

Screenshot 2021-03-16 at 10 03 39

2) Basically, each user has to have own stream of call history

3) When start a call, you need to create a call history record for yourself, e.g:

const CALL_TYPES = {
  INCOMING: 1,
  OUTGOING: 2,
};

const CALL_MEDIA_TYPE = {
  VIDEO: 1,
  AUDIO: 2,
};

const callDataObject = {
  type: CALL_TYPES.OUTGOING,
  mediaType: CALL_MEDIA_TYPE.VIDEO,
  participant_ids: [....],
  duration: 0,
  is_missed: false,
  read: true,
  call_user_id: curerntUserId
};

ConnectyCube.data.create("CallHistory", callDataObject).then(...).catch(...);

4) When other users accept the call, they also create same record for themselves:

  type: CALL_TYPES.INCOMING,
  mediaType: CALL_MEDIA_TYPE.VIDEO,
  participant_ids: [....],
  duration: 0,
  is_missed: false,
  read: true,
  call_user_id: curerntUserId
};

ConnectyCube.data.create("CallHistory", callDataObject).then(...).catch(...);

5) if some user did not accept the call, a call initiator has to create a record form him/herself with is_missed: true:

 const callDataObject = {
  type: CALL_TYPES.INCOMING,
  mediaType: CALL_MEDIA_TYPE.VIDEO,
  participant_ids: [....],
  duration: 0,
  is_missed: false,
  read: false,
  call_user_id: curerntUserId
};

ConnectyCube.data.create("CallHistory", callDataObject).then(...).catch(...);

6) When call is finished, each user has to update one call record and set a proper duration value:

 const callDataObject = {
   id: xxx
   duration: 120
 }
 ConnectyCube.data.update("CallHistory", callDataObject).then(...).catch(...);

7) Get call history for current user:

ConnectyCube.data.list("CallHistory",{call_user_id: curretnUserId}).then(...).catch(...);

8) remove call history of current user:

ConnectyCube.data.delete("CallHistory", [id1]).then(...).catch(...);

delete all:

ConnectyCube.data.delete("CallHistory", {call_user_id: curerntUserId}).then(...).catch(...);
arghyaMatrix commented 3 years ago

Can anyone help with how can I toggle between audio and video call within an ongoing call?

DaveLomber commented 3 years ago

@arghyaMatrix please create another ticket

arghyaMatrix commented 3 years ago

@DaveLomber thanks for your comment. Actually I want to show the call logs on the chat page(where all messages are shown) also like WhatsApp or Skype. Is this achievable by this library? Please help me if anyone have solution for this feature

DaveLomber commented 3 years ago

@arghyaMatrix my above comment is exactly for what you are looking for

DaveLomber commented 3 years ago

Since the flow is provided https://github.com/ConnectyCube/connectycube-reactnative-samples/issues/212#issuecomment-800057232

for all further issue please create new issues

arghyaMatrix commented 3 years ago

but in your comment I have to merge two APIs( call history and chat history api) for the feature which needed big time for looping if long chat history is there. is there anything to send type for message where I can set type to call record?

DaveLomber commented 3 years ago

You do not need to loop through chat history to get call signals

For call history - a separated api is used, based on Data API

What you need is to just perform a single call on app startapp and then call api to create call history when you have a call