The Methods below are available for Audio Chat:
Method | Description |
---|---|
sendAudioChatRequest | Allows logged-in user to initiate an audio call |
cancelAudioChatRequest | Allows logged-in user to cancel the initiated audio call |
acceptAudioChatRequest | Allows logged-in user to accept incoming audio call |
rejectAudioChatRequest | Allows logged-in user to reject incoming audio call |
startAudioChatCall | Starts the audio call in a provided UI container |
endAudioChatCall | Ends the audio call |
sendNoAnswerCall | Sends no answer to the initiator of the call if callee doesn’t accept or reject the call |
sendBusyTone | Sends busy tone to inform the caller that callee is currently busy |
muteAudio | Allows logged in user to mute/unmute his audio |
switchSpeakers | Allows logged-in user to switch the speaker |
Initially, follow the steps mentioned in Initialization section to obtain an instantiated object of the CometChat class. Then use the object to call the methods required to implement the Audio Call feature.
sendAudioChatRequest
Allows logged-in user to initiate an audio call
Method Signature:
sendAudioChatRequest(String toId, Callbacks callback)
Example:
cometChat.sendAudioChatRequest("15", new Callbacks(){
@Override
public void successCallback(JSONObject response){ /* Code Block */ }
@Override
public void failCallback(JSONObject response){ /* Code Block */ }
});
Arguments:
Argument | Description |
---|---|
toId | userId of a callee |
callback | success and failure callbacks |
Response for successCallback:
{
"id": "15",
"callid": "bf1e7055f8e15d6f8662c7c4b6f8adb9"
}
Description:
Response Property | Description |
---|---|
id | userId of a callee |
callid | id of the call session |
cancelAudioChatRequest
Allows logged-in user to cancel the initiated audio call
Method Signature:
cancelAudioChatRequest(String userId, Callbacks callback)
Example:
cometChat.cancelAudioChatRequest("15", new Callbacks(){
@Override
public void successCallback(JSONObject response){ /* Code Block */ }
@Override
public void failCallback(JSONObject response){ /* Code Block */ }
});
Arguments:
Argument | Description |
---|---|
userId | id of a callee |
callback | success and failure callbacks |
Response for successCallback:
{
"id":"15"
}
Description:
Response Property | Description |
---|---|
id | userId of a callee |
acceptAudioChatRequest
Allows logged-in user to accept incoming audio call
Method Signature:
acceptAudioChatRequest(String userId, Callbacks callback)
Example:
cometChat.acceptAudioChatRequest("16", new Callbacks(){
@Override
public void successCallback(JSONObject response){ /* Code Block */ }
@Override
public void failCallback(JSONObject response){ /* Code Block */ }
});
Arguments:
Argument | Description |
---|---|
userId | userId of a caller |
callback | success and failure callbacks |
Response for successCallback:
{
"id":"16"
}
Description:
Response Property | Description |
---|---|
id | userId of a caller |
rejectAudioChatRequest
Allows logged-in user to reject incoming audio call
Method Signature:
rejectAudioChatRequest(String userId, String callId, Callbacks callback)
Example:
cometChat.rejectAudioChatRequest("16", "bf1e7055f8e15d6f8662c7c4b6f8adb9", new Callbacks(){
@Override
public void successCallback(JSONObject response){ /* Code Block */ }
@Override
public void failCallback(JSONObject response){ /* Code Block */ }
});
Agruments:
Argument | Description |
---|---|
userId | userId of a caller |
callId | id of a call received in onAvchatMessageReceived() callback |
callback | success and failure callbacks |
Response for successCallback:
{
"id":"16"
}
Description:
Response Property | Description |
---|---|
id | userId of a caller |
startAudioChatCall
Starts the audio call in a provided UI container
Method Signature:
startAudioChatCall(Context context, String callid,RelativeLayout container,Callbacks callbacks)
Example:
cometChat.startAudioChatCall(MainActivity.this, "bf1e7055f8e15d6f8662c7c4b6f8adb9 ",container,new Callbacks({
@Override
public void failCallback(JSONObject response){ /* Code Block */ }
});
Arguments:
Argument | Description |
---|---|
context | context of the activity |
callId | id of a call received in onAvchatMessageReceived() callback |
container | UI container to hold Audio Call UI |
callback | failure callbacks |
endAudioChatCall
Ends the audio call
Method Signature:
endAudioChatCall(String userId, String callId, Callbacks callback)
Example:
cometChat.endAudioChatCall("15", "bf1e7055f8e15d6f8662c7c4b6f8adb9", new Callbacks(){
@Override
public void successCallback(JSONObject response){ /* Code Block */ }
@Override
public void failCallback(JSONObject response){ /* Code Block */ }
});
Arguments:
Argument | Description |
---|---|
userId | userId of other chat participant |
callId | id of a call received in onAvchatMessageReceived() callback |
callback | success and failure callbacks |
Response for successCallback:
{
"id": "15"
}
Description:
Response Property | Description |
---|---|
id | userId of other chat participant |
sendNoAnswerCall
Sends no answer to the initiator of the call if callee doesn’t accept or reject the call
Method Signature:
sendNoAnswerCall(String userId, Callbacks callback)
Example:
cometChat.sendNoAnswerCall("15", new Callbacks(){
@Override
public void successCallback(JSONObject response){ /* Code Block */ }
@Override
public void failCallback(JSONObject response){ /* Code Block */ }
});
Arguments:
Argument | Description |
---|---|
userId | id of a group to delete |
callback | success and failure callbacks |
Response for successCallback:
{
"id": "15"
}
Description:
Response Property | Description |
---|---|
id | userId of the caller |
sendBusyTone
Sends busy tone to inform the caller that callee is currently busy
Method Signature:
sendBusyTone(String userId, Callbacks callback)
Example:
cometChat.sendBusyTone("15", new Callbacks(){
@Override
public void successCallback(JSONObject response){ /* Code Block */ }
@Override
public void failCallback(JSONObject response){ /* Code Block */ }
});
Arguments:
Argument | Description |
---|---|
userId | id of a group to delete |
callback | success and failure callbacks |
Response for successCallback:
{
"id": "15"
}
Description:
Response Property | Description |
---|---|
id | userId of the caller |
muteAudio
Allows logged in user to mute/unmute the audio
Method Signature:
muteAudio(Boolean flag)
Example:
cometChat.muteAudio(true);
Arguments:
Argument | Description |
---|---|
flag | turn audio on/off |
switchSpeakers
Allows logged-in user to switch the speaker
Method Signature:
switchSpeakers()
Example:
cometChat.switchSpeakers();