This commit is contained in:
ImBenji
2026-05-05 09:49:06 +01:00
parent 37fef7de25
commit 8939cf38c2
3 changed files with 9 additions and 5 deletions
+6 -2
View File
@@ -92,7 +92,10 @@ class _ViewerScreenState extends State<ViewerScreen> {
return;
}
_sig.send({'type': 'join', 'roomId': roomId});
// build the peer connection BEFORE telling the server we've joined,
// otherwise the host's offer can race in before _pc exists and the
// whole answer step gets silently dropped
await _initPeerConnection(roomId);
_sigSub = _sig.messages.listen(
(msg) => _onSignal(msg, roomId),
@@ -100,6 +103,8 @@ class _ViewerScreenState extends State<ViewerScreen> {
setState(() => _status = 'Signal error: $e');
},
);
_sig.send({'type': 'join', 'roomId': roomId});
}
Future<void> _onSignal(Map<String, dynamic> msg, String roomId) async {
@@ -108,7 +113,6 @@ class _ViewerScreenState extends State<ViewerScreen> {
switch (type) {
case 'joined':
setState(() => _status = 'Waiting for host offer...');
await _initPeerConnection(roomId);
break;
case 'signal':