Handling call events

Listening to the call events#

In order to listen to the call events you need to listen to the Plugin Events using the below methods.

info

The call events mentioned below will return the JSON response. You can decode it to get the details for these events.

Mirrorfly.onMissedCall.listen((missedCallEvents){
//This listener will alert you about missed call notifications.
});
Mirrorfly.onLocalVideoTrackAdded.listen((localTrackEvent) {
//This listener will notify when the local video track is added and starts streaming.
});
Mirrorfly.onRemoteVideoTrackAdded.listen((remoteTrackEvent) {
//This listener will notify when the remote user video track is added and starts streaming.
});
Mirrorfly.onCallStatusUpdated.listen((onCallStatusUpdateEvent) {
//This listener will notify about the Ongoing call status of the caller and callee.
});
Mirrorfly.onCallAction.listen((onCallActionEvent) {
//This listener will notify about the ongoing call actions of the caller and callee.
});
Mirrorfly.onMuteStatusUpdated.listen((onMuteStatusUpdateEvent) {
//This listener will notify about the Mute/unmute audio and video actions of the caller and callee.
});
Mirrorfly.onUserSpeaking.listen((onUserSpeakingEvent) {
//This listener will notify about the speaking events of the caller and callee.
});
Mirrorfly.onUserStoppedSpeaking.listen((onUserStoppedSpeakingEvent) {
//This listener will notify when the caller or callee stops talking.
});
info

AudioLevel ranges from 0 to 10, 0 being very low sound and 10 being too loud.

Handling mute events#

Whenever call end user mute/unmute video or audio, the below listener will be triggered.

Mirrorfly.onMuteStatusUpdated.listen((onMuteStatusUpdateEvent) {
// parse a onMuteStatusUpdateEvent JSON string into a Dart object
var muteStatus = jsonDecode(onMuteStatusUpdateEvent);
var muteEvent = muteStatus["muteEvent"].toString();
var userJid = muteStatus["userJid"].toString();
switch (muteEvent){
case MuteStatus.remoteAudioMute:
break;
case MuteStatus.remoteAudioUnMute:
break;
case MuteStatus.remoteVideoMute:
break;
case MuteStatus.remoteVideoUnMute:
break;
}
});

muteEvent value will be anyone of the values of annotation class MuteEvent.

muteEvent ValueCall event
MuteStatus.remoteVideoMutewhen the remote user muted his video
MuteStatus.remoteVideoUnMutewhen the remote user unmuted his video
MuteStatus.remoteAudioMutewhen the remote user muted his audio
MuteStatus.remoteAudioUnMutewhen the remote user unmuted his video

Handling call status events#

Whenever call status changed in video or audio call, the below listener will be triggered.

Mirrorfly.onCallStatusUpdated.listen((onCallStatusUpdateEvent) {
// parse a onCallStatusUpdate Event JSON string into a Dart object
var statusUpdateReceived = jsonDecode(onCallStatusUpdateEvent);
var callMode = statusUpdateReceived["callMode"].toString();
var userJid = statusUpdateReceived["userJid"].toString();
var callType = statusUpdateReceived["callType"].toString();
var callStatus = statusUpdateReceived["callStatus"].toString();
switch (callStatus){
case CallStatus.connecting:
break;
case CallStatus.onResume:
break;
case CallStatus.userJoined:
break;
case CallStatus.userLeft:
break;
case CallStatus.inviteCallTimeout:
break;
case CallStatus.attended:
break;
case CallStatus.disconnected:
break;
case CallStatus.calling10s:
break;
case CallStatus.callingAfter10s:
break;
case CallStatus.calling:
break;
case CallStatus.reconnected:
break;
case CallStatus.ringing:
break;
case CallStatus.onHold:
break;
case CallStatus.connected:
break;
case CallStatus.callTimeout:
break;
}
});

callStatus value will be anyone of the values of annotation class CallStatus.

callStatus ValueCall event
CallStatus.callingthe initial state of the call
CallStatus.connectingThe current call is in connecting state
CallStatus.ringingthe remote user is having internet and acknowledged the call
CallStatus.attendedthe user attended call and UI can be presented with the users in the call
CallStatus.connectedthe call is successfully connected and audio/video tracks transmission is about to start
CallStatus.disconnectedthe call is disconnected and call UI can be closed
CallStatus.reconnectedthe call is connected back after a reconnecting state
CallStatus.onHoldthe remote user has put your call on hold, it will happedn when the remote user attended gsm call
CallStatus.onResumethe remote user has resumed your call after a on hold, it will happen when the remote user disconnected gsm call
CallStatus.callTimeoutwhen we don't receive ack for the outgoing call from the remote user within 30 seconds, When we don't receive ack for the incoming call from the caller within 30 seconds, When we don't receive ack for the call invite from the invited user within 30 seconds

Handling call action events#

Whenever call action received in video or audio call, the below delegate will be triggered,

Mirrorfly.onCallAction.listen((onCallActionEvent) {
// parse a onCallActionEvent JSON string into a Dart object
var actionReceived = jsonDecode(onCallActionEvent);
var callAction = actionReceived["callAction"].toString();
var userJid = actionReceived["userJid"].toString();
var callMode = actionReceived["callMode"].toString();
var callType = actionReceived["callType"].toString();
switch(callAction){
case CallAction.localHangup:
break;
case CallAction.remoteBusy:
break;
case CallAction.remoteHangup:
break;
case CallAction.remoteEngaged:
break;
case CallAction.audioDeviceChanged:
break;
case CallAction.denyCall:
break;
case CallAction.cameraSwitchSuccess:
break;
case CallAction.changedToAudioCall:
break;
case CallAction.videoCallConversionCancel:
break;
case CallAction.videoCallConversionRequest:
break;
case CallAction.videoCallConversionAccepted:
break;
case CallAction.videoCallConversionRejected:
break;
}
});

callAction value will be anyone of the values of annotation class CallAction.

callAction ValueCall event
CallAction.localHangupwhenever you disconnect the call, the action will be received
CallAction.remoteHangupwhenever remote user disconnect the call, the action will be received
CallAction.denyCallwhen you decline the incoming call, the action will be received for callee
CallAction.remoteEngagedwhen the remote user is engaged in the another call, the action will be received for the caller
CallAction.remoteBusywhen the remote user declines incoming the call, the action will be received for the caller
CallAction.audioDeviceChangedwhenever the audio device changed in call, update the audio device UI
CallAction.videoCallConversionRejectedWhen remote user declined our video call switch request
CallAction.videoCallConversionAcceptedWhen remote user accepted our video call switch request
CallAction.videoCallConversionCancelWhen remote user cancels the video call switch request made by them
CallAction.cameraSwitchSuccessWhen camera switch done, the action will be received
CallAction.changedToAudioCallWhen ui needs to be changed as audio call ui this action will be received
CallAction.videoCallConversionRequestWhen Remote user request to switch Audio call to Video call this action will be received