iceCandidateEvent method
Handles the iceCandidateEvent response
Implementation
Future<void> iceCandidateEvent(Map<String, dynamic> params) async {
final iceCandidate = RTCIceCandidate(
params['candidate'],
params['sdpMid'],
params['sdpMLineIndex'],
);
final connectionId = params['senderConnectionId'];
final isRemote = session.localParticipant!.connectionId != connectionId;
final participant = isRemote
? session.remoteParticipants[connectionId]
: session.localParticipant;
final pc = participant!.peerConnection;
switch (pc!.signalingState) {
case RTCSignalingState.RTCSignalingStateClosed:
_logger
.warning('saveIceCandidate error: PeerConnection object is closed');
break;
case RTCSignalingState.RTCSignalingStateStable:
if (await pc.getRemoteDescription() != null) {
pc.addCandidate(iceCandidate);
} else {
participant.iceCandidateList.add(iceCandidate);
}
break;
default:
participant.iceCandidateList.add(iceCandidate);
}
}