Stabilizza live YouTube/RTMP e fix crash rotazione mobile.
Pipeline YouTube con relay, overlay e publisher sync lato backend; fix GL pauseGlDuringRotation su Android per evitare crash in rotazione durante lo streaming Flutter. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -26,6 +26,7 @@ class WebsocketService {
|
||||
ActionCable? _cable;
|
||||
ActionChannel? _channel;
|
||||
String? _sessionId;
|
||||
Future<void>? _connectOp;
|
||||
|
||||
bool get isConnected => _cable != null && _channel != null;
|
||||
|
||||
@@ -35,6 +36,24 @@ class WebsocketService {
|
||||
}) async {
|
||||
if (_sessionId == sessionId && isConnected) return;
|
||||
|
||||
final prev = _connectOp;
|
||||
if (prev != null) await prev.catchError((_) {});
|
||||
|
||||
_connectOp = _connect(sessionId: sessionId, deviceRole: deviceRole);
|
||||
final op = _connectOp!;
|
||||
try {
|
||||
await op;
|
||||
} finally {
|
||||
if (identical(_connectOp, op)) {
|
||||
_connectOp = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _connect({
|
||||
required String sessionId,
|
||||
required String deviceRole,
|
||||
}) async {
|
||||
await disconnect();
|
||||
|
||||
final token = _ref.read(authProvider).accessToken;
|
||||
@@ -161,11 +180,20 @@ class WebsocketService {
|
||||
}
|
||||
|
||||
Future<void> disconnect() async {
|
||||
_channel?.unsubscribe();
|
||||
final channel = _channel;
|
||||
final cable = _cable;
|
||||
_channel = null;
|
||||
_cable?.disconnect();
|
||||
_cable = null;
|
||||
_sessionId = null;
|
||||
|
||||
try {
|
||||
channel?.unsubscribe();
|
||||
} catch (_) {}
|
||||
try {
|
||||
cable?.disconnect();
|
||||
} catch (_) {}
|
||||
|
||||
await Future<void>.delayed(const Duration(milliseconds: 150));
|
||||
_ref.read(sessionProvider.notifier).setConnected(false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user