- Android
- iOS
- JavaScript
- Flutter
- ReactNative
For in-call event listeners, register them on the ICallSession object.
mCallSession.addListener("SingleCallActivity", this);
The callback events are defined as follows.
interface ICallSessionListener {
//call connected
void onCallConnect();
//call ended
void onCallFinish(CallConst.CallFinishReason finishReason);
//in-call error callback
void onErrorOccur(CallConst.CallErrorCode errorCode);
// a user is invited (group calls only)
void onUsersInvite(String inviterId, List<String> userIdList);
// a user joins the call (group calls only)
void onUsersConnect(List<String> userIdList);
// a user leaves the call (group calls only)
void onUsersLeave(List<String> userIdList);
// a user enables or disables the camera
void onUserCameraEnable(String userId, boolean enable);
// a user unmutes or mutes the microphone
void onUserMicrophoneEnable(String userId, boolean enable);
// a user's audio level changes
// userId is the key and audio level is the value
void onSoundLevelUpdate(HashMap<String, Float> soundLevels);
// callback triggered when the first video frame is rendered
void onVideoFirstFrameRender(String userId);
}
For in-call event listeners, register them on the id<JCallSession> object.
[callSession addDelegate:self];
The events are defined as follows.
@protocol JCallSessionDelegate <NSObject>
@optional
/// call connected
- (void)callDidConnect;
/// call ended
/// - Parameter finishReason: end reason
- (void)callDidFinish:(JCallFinishReason)finishReason;
/// a user is invited (group calls only)
/// - Parameter userId: invited user's ID
- (void)userDidInvite:(NSString *)userId;
/// a user joins the call (group calls only)
/// - Parameter userId: user ID
- (void)userDidConnect:(NSString *)userId;
/// a user leaves the call (group calls only)
/// - Parameter userId: user ID
- (void)userDidLeave:(NSString *)userId;
/// a user enables or disables the camera
/// - Parameters:
/// - enable: whether enabled
/// - userId: user ID
- (void)userCamaraDidChange:(BOOL)enable
userId:(NSString *)userId;
/// a user unmutes or mutes the microphone
/// - Parameters:
/// - enable: whether enabled
/// - userId: user ID
- (void)userMicrophoneDidChange:(BOOL)enable
userId:(NSString *)userId;
/// user audio-level change callback
/// - Parameter soundLevels: dictionary whose keys are user IDs and values are audio levels
- (void)soundLevelDidUpdate:(NSDictionary<NSString *,NSNumber *> *)soundLevels;
/// callback triggered when the first video frame is rendered
/// - Parameter userId: user ID
- (void)videoFirstFrameDidRender:(NSString *)userId;
/// in-call error callback
/// - Parameter errorCode: error code
- (void)errorDidOccur:(JCallErrorCode)errorCode;
@end
let { CallEvent } = JuggleCall;
// A member joined the call; display the video DOM node
juggleCall.on(CallEvent.MEMBER_JOINED, (event) => {
let { target: { callId, member } } = event;
let session = juggleCall.getSession({ callId });
let userId = member.id;
// createVideo creates a video node
let el = createVideo(userId);
session.setVideoView([{ userId, videoElement: el }]);
console.log('CallEvent.MEMBER_JOINED', event);
});
// A member left the call; remove the video DOM node
juggleCall.on(CallEvent.MEMBER_QUIT, (event) => {
let { target: { member } } = event;
console.log('CallEvent.MEMBER_QUIT', event);
});
// returned after the call ends
juggleCall.on(CallEvent.CALL_FINISHED, (event) => {
console.log('CallEvent.CALL_FINISHED', event);
let { callId, callStatus, isMultiCall, members} = event;
// members contains the disconnection reason for each user
// members[0] => { id: '', reason: 1 }
});
Enum values for each user disconnection:
| Key | Value | Meaning |
|---|---|---|
| CallFinishedReason.HANGUP | 1 | Current user hangs up an answered incoming call. |
| CallFinishedReason.DECLINE | 2 | Current user declines an incoming call. |
| CallFinishedReason.BUSY | 3 | Current user is busy. |
| CallFinishedReason.NO_RESPONSE | 4 | Current user does not answer. |
| CallFinishedReason.CANCEL | 5 | Current user cancels the call. |
| CallFinishedReason.OTHER_SIDE_HANGUP | 6 | Remote user hangs up an answered call. |
| CallFinishedReason.OTHER_SIDE_DECLINE | 7 | Remote user declines the call. |
| CallFinishedReason.OTHER_SIDE_BUSY | 8 | Remote user is busy. |
| CallFinishedReason.OTHER_SIDE_NO_RESPONSE | 9 | Remote user does not answer. |
| CallFinishedReason.OTHER_SIDE_CANCEL | 10 | Remote user cancels the call. |
| CallFinishedReason.ROOM_DESTROY | 11 | Room was destroyed. |
| CallFinishedReason.NETWORK_ERROR | 12 | Network error. |
Use the CallSession object to listen for in-call events.
The callback events are defined as follows.
//call connected
Function()? onCallConnect;
//call ended
Function(int finishReason)? onCallFinish;
// a user is invited (group calls only)
Function(List<String> userIdList, String inviterId)? onUsersInvite;
// a user joins the call (group calls only)
Function(List<String> userIdList)? onUsersConnect;
// a user leaves the call (group calls only)
Function(List<String> userIdList)? onUsersLeave;
// a user enables or disables the camera
Function(String userId, bool enable)? onUserCameraChange;
// a user unmutes or mutes the microphone
Function(String userId, bool enable)? onUserMicrophoneChange;
//in-call error callback
Function(int errorCode)? onErrorOccur;
// a user's audio level changes
// userId is the key and audio level is the value
Function(Map<String, double>)? onSoundLevelUpdate;
// callback triggered when the first video frame is rendered
Function(String userId)? onVideoFirstFrameRender;
Use the CallSession object to listen for in-call events.
The callback events are defined as follows:
interface CallSessionListener {
//call connected
onCallConnect?: () => void;
//call ended
onCallFinish?: (finishReason: number) => void;
// a user is invited (group calls only)
onUsersInvite?: (userIdList: string[], inviterId: string) => void;
// a user joins the call (group calls only)
onUsersConnect?: (userIdList: string[]) => void;
// a user leaves the call (group calls only)
onUsersLeave?: (userIdList: string[]) => void;
// a user enables or disables the camera
onUserCameraChange?: (userId: string, enable: boolean) => void;
// a user unmutes or mutes the microphone
onUserMicrophoneChange?: (userId: string, enable: boolean) => void;
//in-call error callback
onErrorOccur?: (errorCode: number) => void;
// a user's audio level changes
// userId is the key and audio level is the value
onSoundLevelUpdate?: (soundLevels: Map<string, number>) => void;
// callback triggered when the first video frame is rendered
onVideoFirstFrameRender?: (userId: string) => void;
}