Skip to content

Commit 39d792d

Browse files
committed
refactor: extract _sendRenegotiationUpdate from onRenegotiationNeeded callback
1 parent 150e3b9 commit 39d792d

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

lib/features/call/bloc/call_bloc.dart

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2784,19 +2784,24 @@ class CallBloc extends Bloc<CallEvent, CallState> with WidgetsBindingObserver im
27842784
onIceCandidate: (candidate) => add(_PeerConnectionEvent.iceCandidateIdentified(callId, candidate)),
27852785
onAddStream: (stream) => add(_PeerConnectionEvent.streamAdded(callId, stream)),
27862786
onRemoveStream: (stream) => add(_PeerConnectionEvent.streamRemoved(callId, stream)),
2787-
onRenegotiationNeeded: (pc) => _renegotiationHandler.handle(callId, lineId, pc, (callId, lineId, jsep) async {
2788-
final updateRequest = UpdateRequest(
2789-
transaction: WebtritSignalingClient.generateTransactionId(),
2790-
line: lineId,
2791-
callId: callId,
2792-
jsep: jsep.toMap(),
2793-
);
2794-
await _signalingClient?.execute(updateRequest);
2795-
}),
2787+
onRenegotiationNeeded: (pc) => _renegotiationHandler.handle(callId, lineId, pc, _sendRenegotiationUpdate),
27962788
),
27972789
);
27982790
}
27992791

2792+
/// Sends a renegotiation [UpdateRequest] to the signaling server with the given [jsep] offer.
2793+
///
2794+
/// Used as a [RenegotiationExecutor] callback by [RenegotiationHandler].
2795+
Future<void> _sendRenegotiationUpdate(String callId, int? lineId, RTCSessionDescription jsep) async {
2796+
final updateRequest = UpdateRequest(
2797+
transaction: WebtritSignalingClient.generateTransactionId(),
2798+
line: lineId,
2799+
callId: callId,
2800+
jsep: jsep.toMap(),
2801+
);
2802+
await _signalingClient?.execute(updateRequest);
2803+
}
2804+
28002805
void _addToRecents(ActiveCall activeCall) {
28012806
final number = activeCall.handle.value;
28022807
final username = activeCall.displayName;

0 commit comments

Comments
 (0)