- Alex initiates the call to Bob using the initiateCall() method.
- Bob now has two choices:
- Accept the call from Alex using the acceptCall() method.
- Reject the call from Alex using the rejectCall() method passing the status as
rejected
.
- In the meantime, Alex has the option to cancel the call he initiated to Bob using the rejectCall() method passing the status as
cancelled
. - If Bob accepts the call from Alex, both Alex and Bob need to call the startSession() method. Alex in the onOutgoingCallAccepted() method of the
CallListener
and Bob in the success obtained from the acceptCall() method and both will be connected to each other.
Initiate Call
TheinitiateCall()
method sends a call request to a user or a group.
Call
class. The constructor for Call
class takes the following parameters:
Parameter | Description |
---|---|
receiverID | The UID or GUID of the recipient |
receiverType | The type of the receiver can be, 1.CometChat.RECEIVER_TYPE.USER 2.CometChat.RECEIVER_TYPE.GROUP |
callType | The type of call can be, 1.CometChat.CALL_TYPE.AUDIO 2.CometChat.CALL_TYPE.VIDEO |
Call
object is returned with the details of the call including a unique session ID for the call.
Receive Calls
Wherever you wish to receive the call events in, you need to register theCallListener
listener using the addCallListener()
method. onCallEndedMessageReceived()
event will receive when you trigger CometChat.endCall(sessionID).
Parameter | Description |
---|---|
listenerID | An ID that uniquely identifies that listener. We recommend using the activity or fragment name |
- The receiver of the call accepts the call.
- The receiver of the call rejects the call.
- The initiator of the call cancels the call.
Accept the Incoming Call
Once you have received an incoming call from a user or in any group, to accept the call using theacceptCall()
method.
Parameter | Description |
---|---|
sessionID | The unique session ID available in the Call object |
Reject the Incoming Call
As the call is being rejected by the receiver of the call, you need to pass the status asCometChat.CALL_STATUS.REJECTED
to the rejectCall()
method.
Parameter | Description |
---|---|
sessionID | The unique session ID available in the Call object. |
status | Reason for rejection of the call. |
Cancel the Outgoing Call
As the call is being canceled by the initiator of the call, you need to pass the status asCometChat.CALL_STATUS.CANCELLED
to the rejectCall()
method.
Parameter | Description |
---|---|
sessionID | The unique session ID available in the Call object. |
status | Reason for rejection of the call. |