From beda7fc2e6243c8c55607fa6e47953205d1d7955 Mon Sep 17 00:00:00 2001 From: Haitao Pan Date: Wed, 3 Jun 2026 12:34:26 +0800 Subject: [PATCH] fix(webrtc): pass SDP offer and answer as object to conform to backend format --- lib/features/desktop/desktop_client.dart | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/features/desktop/desktop_client.dart b/lib/features/desktop/desktop_client.dart index 455a206b..d18cf3ca 100644 --- a/lib/features/desktop/desktop_client.dart +++ b/lib/features/desktop/desktop_client.dart @@ -87,7 +87,7 @@ class DesktopClient { method: 'xworkmate.desktop.offer', params: { 'sessionId': sessionId, - 'sdpOffer': offer.sdp, + 'sdpOffer': offer.toMap(), 'display': display, 'width': width.toString(), 'height': height.toString(), @@ -97,13 +97,21 @@ class DesktopClient { }, ); - final sdpAnswer = response['result']?['sdpAnswer'] as String?; - if (sdpAnswer == null) { + final sdpAnswerData = response['result']?['sdpAnswer']; + if (sdpAnswerData == null) { throw Exception('Bridge failed to return SDP Answer'); } // Apply SDP Answer - final answer = RTCSessionDescription(sdpAnswer, 'answer'); + late RTCSessionDescription answer; + if (sdpAnswerData is Map) { + answer = RTCSessionDescription( + sdpAnswerData['sdp'] as String?, + sdpAnswerData['type'] as String? ?? 'answer', + ); + } else { + answer = RTCSessionDescription(sdpAnswerData.toString(), 'answer'); + } await _peerConnection!.setRemoteDescription(answer); _isConnecting = false;